Libevent Code Doxygen document
http_struct.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2000-2007 Niels Provos <provos@citi.umich.edu>
3  * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * 3. The name of the author may not be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 #ifndef EVENT2_HTTP_STRUCT_H_INCLUDED_
28 #define EVENT2_HTTP_STRUCT_H_INCLUDED_
29 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 #include <event2/event-config.h>
42 #ifdef EVENT__HAVE_SYS_TYPES_H
43 #include <sys/types.h>
44 #endif
45 #ifdef EVENT__HAVE_SYS_TIME_H
46 #include <sys/time.h>
47 #endif
48 
49 /* For int types. */
50 #include <event2/util.h>
51 
58 #if defined(TAILQ_ENTRY)
59  TAILQ_ENTRY(evhttp_request) next;
60 #else
61 struct {
62  struct evhttp_request *tqe_next;
63  struct evhttp_request **tqe_prev;
64 } next;
65 #endif
66 
67  /* the connection object that this request belongs to */
68  struct evhttp_connection *evcon;
69  int flags;
71 #define EVHTTP_REQ_OWN_CONNECTION 0x0001
73 #define EVHTTP_PROXY_REQUEST 0x0002
75 #define EVHTTP_USER_OWNED 0x0004
77 #define EVHTTP_REQ_DEFER_FREE 0x0008
79 #define EVHTTP_REQ_NEEDS_FREE 0x0010
80 
81  struct evkeyvalq *input_headers;
82  struct evkeyvalq *output_headers;
83 
84  /* address of the remote host and the port connection came from */
85  char *remote_host;
86  ev_uint16_t remote_port;
87 
88  /* cache of the hostname for evhttp_request_get_host */
89  char *host_cache;
90 
91  enum evhttp_request_kind kind;
92  enum evhttp_cmd_type type;
93 
94  size_t headers_size;
95  size_t body_size;
96 
97  char *uri; /* uri after HTTP request was parsed */
98  struct evhttp_uri *uri_elems; /* uri elements */
99 
100  char major; /* HTTP Major number */
101  char minor; /* HTTP Minor number */
102 
103  int response_code; /* HTTP Response code */
104  char *response_code_line; /* Readable response */
105 
106  struct evbuffer *input_buffer; /* read data */
107  ev_int64_t ntoread;
108  unsigned chunked:1, /* a chunked request */
109  userdone:1; /* the user has sent all data */
110 
111  struct evbuffer *output_buffer; /* outgoing post or data */
112 
113  /* Callback */
114  void (*cb)(struct evhttp_request *, void *);
115  void *cb_arg;
116 
117  /*
118  * Chunked data callback - call for each completed chunk if
119  * specified. If not specified, all the data is delivered via
120  * the regular callback.
121  */
122  void (*chunk_cb)(struct evhttp_request *, void *);
123 
124  /*
125  * Callback added for forked-daapd so they can collect ICY
126  * (shoutcast) metadata from the http header. If return
127  * int is negative the connection will be closed.
128  */
129  int (*header_cb)(struct evhttp_request *, void *);
130 
131  /*
132  * Error callback - called when error is occured.
133  * @see evhttp_request_error for error types.
134  *
135  * @see evhttp_request_set_error_cb()
136  */
137  void (*error_cb)(enum evhttp_request_error, void *);
138 
139  /*
140  * Send complete callback - called when the request is actually
141  * sent and completed.
142  */
143  void (*on_complete_cb)(struct evhttp_request *, void *);
144  void *on_complete_cb_arg;
145 };
146 
147 #ifdef __cplusplus
148 }
149 #endif
150 
151 #endif /* EVENT2_HTTP_STRUCT_H_INCLUDED_ */
152 
evhttp_request_error
Definition: http.h:574
evhttp_request_kind
Definition: http.h:505
evhttp_cmd_type
Definition: http.h:492
Definition: evbuffer-internal.h:80
Definition: http-internal.h:51
Definition: http_struct.h:57
Definition: http.c:4480