Project

General

Profile

Statistics
| Revision:

root / lab4 / .minix-src / include / event2 / http_struct.h @ 14

History | View | Annotate | Download (4.2 KB)

1 13 up20180614
/*        $NetBSD: http_struct.h,v 1.1.1.2 2015/01/29 06:38:28 spz Exp $        */
2
/*        $NetBSD: http_struct.h,v 1.1.1.2 2015/01/29 06:38:28 spz Exp $        */
3
/*
4
 * Copyright (c) 2000-2007 Niels Provos <provos@citi.umich.edu>
5
 * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson
6
 *
7
 * Redistribution and use in source and binary forms, with or without
8
 * modification, are permitted provided that the following conditions
9
 * are met:
10
 * 1. Redistributions of source code must retain the above copyright
11
 *    notice, this list of conditions and the following disclaimer.
12
 * 2. Redistributions in binary form must reproduce the above copyright
13
 *    notice, this list of conditions and the following disclaimer in the
14
 *    documentation and/or other materials provided with the distribution.
15
 * 3. The name of the author may not be used to endorse or promote products
16
 *    derived from this software without specific prior written permission.
17
 *
18
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
 */
29
#ifndef _EVENT2_HTTP_STRUCT_H_
30
#define _EVENT2_HTTP_STRUCT_H_
31
32
/** @file event2/http_struct.h
33

34
  Data structures for http.  Using these structures may hurt forward
35
  compatibility with later versions of Libevent: be careful!
36

37
 */
38
39
#ifdef __cplusplus
40
extern "C" {
41
#endif
42
43
#include <event2/event-config.h>
44
#ifdef _EVENT_HAVE_SYS_TYPES_H
45
#include <sys/types.h>
46
#endif
47
#ifdef _EVENT_HAVE_SYS_TIME_H
48
#include <sys/time.h>
49
#endif
50
51
/* For int types. */
52
#include <event2/util.h>
53
54
/**
55
 * the request structure that a server receives.
56
 * WARNING: expect this structure to change.  I will try to provide
57
 * reasonable accessors.
58
 */
59
struct evhttp_request {
60
#if defined(TAILQ_ENTRY)
61
        TAILQ_ENTRY(evhttp_request) next;
62
#else
63
struct {
64
        struct evhttp_request *tqe_next;
65
        struct evhttp_request **tqe_prev;
66
}       next;
67
#endif
68
69
        /* the connection object that this request belongs to */
70
        struct evhttp_connection *evcon;
71
        int flags;
72
/** The request obj owns the evhttp connection and needs to free it */
73
#define EVHTTP_REQ_OWN_CONNECTION        0x0001
74
/** Request was made via a proxy */
75
#define EVHTTP_PROXY_REQUEST                0x0002
76
/** The request object is owned by the user; the user must free it */
77
#define EVHTTP_USER_OWNED                0x0004
78
/** The request will be used again upstack; freeing must be deferred */
79
#define EVHTTP_REQ_DEFER_FREE                0x0008
80
/** The request should be freed upstack */
81
#define EVHTTP_REQ_NEEDS_FREE                0x0010
82
83
        struct evkeyvalq *input_headers;
84
        struct evkeyvalq *output_headers;
85
86
        /* address of the remote host and the port connection came from */
87
        char *remote_host;
88
        ev_uint16_t remote_port;
89
90
        /* cache of the hostname for evhttp_request_get_host */
91
        char *host_cache;
92
93
        enum evhttp_request_kind kind;
94
        enum evhttp_cmd_type type;
95
96
        size_t headers_size;
97
        size_t body_size;
98
99
        char *uri;                        /* uri after HTTP request was parsed */
100
        struct evhttp_uri *uri_elems;        /* uri elements */
101
102
        char major;                        /* HTTP Major number */
103
        char minor;                        /* HTTP Minor number */
104
105
        int response_code;                /* HTTP Response code */
106
        char *response_code_line;        /* Readable response */
107
108
        struct evbuffer *input_buffer;        /* read data */
109
        ev_int64_t ntoread;
110
        unsigned chunked:1,                /* a chunked request */
111
            userdone:1;                        /* the user has sent all data */
112
113
        struct evbuffer *output_buffer;        /* outgoing post or data */
114
115
        /* Callback */
116
        void (*cb)(struct evhttp_request *, void *);
117
        void *cb_arg;
118
119
        /*
120
         * Chunked data callback - call for each completed chunk if
121
         * specified.  If not specified, all the data is delivered via
122
         * the regular callback.
123
         */
124
        void (*chunk_cb)(struct evhttp_request *, void *);
125
};
126
127
#ifdef __cplusplus
128
}
129
#endif
130
131
#endif /* _EVENT2_HTTP_STRUCT_H_ */