Code Coverage: vinyl-cache/bin/vinyltest/vtest2/src/vtc_http.h
 
82217aa4fc7094b3610340078afaf78cd95a8ec9
 
0
/*-
1
 * Copyright (c) 2008-2015 Varnish Software AS
2
 * All rights reserved.
3
 *
4
 * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>
5
 *
6
 * SPDX-License-Identifier: BSD-2-Clause
7
 *
8
 * Redistribution and use in source and binary forms, with or without
9
 * modification, are permitted provided that the following conditions
10
 * are met:
11
 * 1. Redistributions of source code must retain the above copyright
12
 *    notice, this list of conditions and the following disclaimer.
13
 * 2. Redistributions in binary form must reproduce the above copyright
14
 *    notice, this list of conditions and the following disclaimer in the
15
 *    documentation and/or other materials provided with the distribution.
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
 * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
21
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27
 * SUCH DAMAGE.
28
 */
29
30
#include "vqueue.h"
31
32 2997
#define MAX_HDR         64
33
34
struct vtc_sess {
35
        unsigned                magic;
36
#define VTC_SESS_MAGIC          0x932bd565
37
        struct vtclog           *vl;
38
        char                    *name;
39
        int                     repeat;
40
        int                     keepalive;
41
        int                     *fd;
42
43
        ssize_t                 rcvbuf;
44
};
45
46
struct h2_window {
47
        uint64_t                init;
48
        int64_t                 size;
49
};
50
51
struct http {
52
        unsigned                magic;
53
#define HTTP_MAGIC              0x2f02169c
54
        int                     *sfd;
55
        struct vtc_sess         *sess;
56
        vtim_dur                timeout;
57
        struct vtclog           *vl;
58
59
        struct vsb              *vsb;
60
61
        int                     rcvbuf;
62
        int                     nrxbuf;
63
        char                    *rx_b;
64
        char                    *rx_p;
65
        char                    *rx_e;
66
        char                    *rem_ip;
67
        char                    *rem_port;
68
        char                    *rem_path;
69
        char                    *body;
70
        long                    bodyl;
71
        char                    bodylen[20];
72
        char                    chunklen[20];
73
74
        char                    *req[MAX_HDR];
75
        char                    *resp[MAX_HDR];
76
77
        int                     gziplevel;
78
        int                     gzipresidual;
79
80
        int                     head_method;
81
82
        int                     fatal;
83
84
        /* H/2 */
85
        unsigned                h2;
86
        int                     wf;
87
        int                     no_rfc7540_priorities;
88
89
        pthread_t               tp;
90
        VTAILQ_HEAD(, stream)   streams;
91
        unsigned                last_stream;
92
        pthread_mutex_t         mtx;
93
        pthread_cond_t          cond;
94
        struct hpk_ctx          *encctx;
95
        struct hpk_ctx          *decctx;
96
        struct h2_window        h2_win_self[1];
97
        struct h2_window        h2_win_peer[1];
98
};
99
100
void http_process(struct vtclog *vl, struct vtc_sess *vsp, const char *spec,
101
    int *sock, int *sfd, const char *addr, int rcvbuf);
102