• Home
  • Raw
  • Download

Lines Matching +full:data +full:- +full:uri +full:- +full:to +full:- +full:buffer

2  * Copyright (c) 2000-2007 Niels Provos <provos@citi.umich.edu>
3 * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson
13 * 3. The name of the author may not be used to endorse or promote products
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
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
50 * need to write HTTP code. The following prototypes and definitions provide
58 #define HTTP_MOVEPERM 301 /**< the uri moved permanently */
59 #define HTTP_MOVETEMP 302 /**< the uri moved temporarily */
62 #define HTTP_NOTFOUND 404 /**< could not find content for uri */
63 #define HTTP_BADMETHOD 405 /**< method not allowed for this uri */
80 * @param base (optional) the event base to receive the HTTP events
81 * @return a pointer to a newly initialized evhttp server structure or NULL
91 * Can be called multiple times to bind the same http server
92 * to multiple different ports.
94 * @param http a pointer to an evhttp object
95 * @param address a string containing the IP address to listen(2) on
96 * @param port the port number to listen on
97 * @return 0 on success, -1 on failure.
108 * @param http a pointer to an evhttp object
109 * @param address a string containing the IP address to listen(2) on
110 * @param port the port number to listen on
120 * This may be useful to create a socket and then fork multiple instances
123 * permissions to bind to a low-numbered port.
125 * Can be called multiple times to have the http server listen to
128 * @param http a pointer to an evhttp object
130 * @return 0 on success, -1 on failure.
141 * @param http a pointer to an evhttp object
150 * The most low-level evhttp_bind/accept method: takes an evconnlistener, and
158 * Return the listener used to implement a bound socket.
165 * Applies the function specified in the first argument to all
167 * attempt to free or remove any connections, sockets or listeners
170 * @param http pointer to an evhttp object
171 * @param function function to apply to every bound socket
172 * @param argument pointer value passed to function for every socket iterated
190 * @param http a pointer to an evhttp object
212 * @param http the evhttp server object to be freed
226 Set the value to use for the Content-Type header when none was provided. If
227 the content type string is NULL, the Content-Type header will not be
230 @param http the http server on which to set the default content type
231 @param content_type the value for the Content-Type header
239 server, and passed to user callbacks.
245 @param http the http server on which to set the methods
252 Set a callback for a specified URI
254 @param http the http sever on which to set the callback
255 @param path the path for which to invoke the callback
258 @return 0 on success, -1 if the callback existed already, -2 on failure
264 /** Removes the callback for a specified URI */
275 @param http the evhttp server object for which to set the callback
276 @param cb the callback to invoke for any unmatched requests
284 Set a callback used to create new bufferevents for connections
285 to a given evhttp object.
287 You can use this to override the default bufferevent type -- for example,
288 to make this evhttp object use SSL bufferevents rather than unencrypted
293 @param http the evhttp server object for which to set the callback
294 @param cb the callback to invoke for incoming connections
302 Adds a virtual host to the http server.
311 It is possible to have hierarchical vhosts. For example: A vhost
315 @param http the evhttp object to which to add a virtual host
319 @param vhost the virtual host to add the regular http server.
320 @return 0 on success, -1 on failure
330 @param http the evhttp object from which to remove the virtual host
331 @param vhost the virtual host to remove from the regular http server.
332 @return 0 on success, -1 on failure
339 Add a server alias to an http object. The http object can be a virtual
343 @param alias the alias to add
353 @param alias the alias to remove
393 * Send an HTML error message to the client.
405 * Send an HTML reply to the client.
407 * The body of the reply consists of the data in databuf. After calling
408 * evhttp_send_reply() databuf will be empty, but the buffer is still
409 * owned by the caller and needs to be deallocated by the caller if
413 * @param code the HTTP response code to send
414 * @param reason a brief message to send with the response code
421 /* Low-level response interface, for streaming/chunked replies */
424 Initiate a reply that uses Transfer-Encoding chunked.
426 This allows the caller to stream the reply back to the client and is
427 useful when either not all of the reply data is immediately available
430 The caller needs to supply data chunks with evhttp_send_reply_chunk()
434 @param code the HTTP response code to send
435 @param reason a brief message to send with the response code
442 Send another data chunk as part of an ongoing chunked reply.
444 The reply chunk consists of the data in databuf. After calling
445 evhttp_send_reply_chunk() databuf will be empty, but the buffer is
446 still owned by the caller and needs to be deallocated by the caller
450 @param databuf the data chunk to send as part of the reply.
457 Send another data chunk as part of an ongoing chunked reply.
459 The reply chunk consists of the data in databuf. After calling
460 evhttp_send_reply_chunk() databuf will be empty, but the buffer is
461 still owned by the caller and needs to be deallocated by the caller
465 @param databuf the data chunk to send as part of the reply.
488 * By default, only some of these methods are accepted and passed to user
489 * callbacks; use evhttp_set_allowed_methods() to change which methods
508 * Create and return a connection object that can be used to for making HTTP
509 * requests. The connection object tries to resolve address and establish the
512 * @param base the event_base to use for handling the connection
513 * @param dnsbase the dns_base to use for resolving host names; if not
515 * @param bev a bufferevent to use for connecting to the server; if NULL, a
516 * socket-based bufferevent will be created. This buffrevent will be freed
518 * @param address the address to which to connect
519 * @param port the port to connect to
540 * Creates a new request object that needs to be filled in with the request
549 * Enable delivery of chunks to requestor.
550 * @param cb will be called after every read of data with the same argument
552 * response. May drain the input buffer; it will be drained
612 * Set a callback to be called on request completion of evhttp_send_* function.
615 * the output data has been written and before the evhttp_request object
632 * Create and return a connection object that can be used to for making HTTP
633 * requests. The connection object tries to resolve address and establish the
636 * @param base the event_base to use for handling the connection
637 * @param dnsbase the dns_base to use for resolving host names; if not
639 * @param address the address to which to connect
640 * @param port the port to connect to
658 /* Try to read error, since server may already send and close
659 * connection, but if at that time we have some data to send then we
664 /* Padding for public flags, @see EVHTTP_CON_* in http-internal.h */
679 * Can be used in a request callback to keep onto the request until
692 * The user needs to either free the request explicitly or call
718 * Can be used to tell libevent to free the connection object after
734 /** Sets the timeout in seconds for events related to this connection */
739 /** Sets the timeout for events related to this connection. Takes a struct
746 * used if evhttp_connection_set_retries is used to make the number of retries
753 /** Sets the retry limit for this connection - -1 repeats indefinitely */
773 * otherwise it return pointer to struct sockaddr_storage */
784 @param evcon the evhttp_connection object over which to send the request
787 @param uri the URI associated with the request
788 @return 0 on success, -1 on failure
794 enum evhttp_cmd_type type, const char *uri);
802 evhttp_connection object is going to get reset.
807 @param req the evhttp_request to cancel; req becomes invalid after this call.
813 * A structure to hold a parsed URI or Relative-Ref conforming to RFC3986.
817 /** Returns the request URI */
820 /** Returns the request URI (parsed) */
838 /** Returns the input buffer */
841 /** Returns the output buffer */
845 URI, the host part of that is preferred. Otherwise, the input headers are
846 searched for a Host: header. NULL is returned if no absolute URI or Host:
854 Finds the value belonging to a header.
856 @param headers the evkeyvalq object in which to find the header
857 @param key the name of the header to find
858 @returns a pointer to the value for the header or NULL if the header
869 @param headers the evkeyvalq object from which to remove a header
870 @param key the name of the header to remove
871 @returns 0 if the header was removed, -1 otherwise.
878 Adds a header to a list of existing headers.
880 @param headers the evkeyvalq object to which to add a header
882 @param value the value belonging to the header
883 @returns 0 on success, -1 otherwise.
892 @param headers the evkeyvalq object from which to remove all headers
901 Helper function to encode a string for inclusion in a URI. All
902 characters are replaced by their hex-escaped (%22) equivalents,
903 except for characters explicitly unreserved by RFC3986 -- that is,
909 @return a newly allocated URI-encoded string or NULL on failure
916 as being 'size' bytes long. This allows you to encode strings that
917 may contain 0-valued bytes.
922 @param size the length of the string to encode, or -1 if the string
923 is NUL-terminated
926 @return a newly allocate URI-encoded string, or NULL on failure.
932 Helper function to sort of decode a URI-encoded string. Unlike
935 before. This is not a good way to decode URIs in whole or in part.
939 @deprecated This function is deprecated; you probably want to use
942 @param uri an encoded URI
943 @return a newly allocated unencoded URI or NULL on failure
946 char *evhttp_decode_uri(const char *uri);
949 Helper function to decode a URI-escaped string or HTTP parameter.
952 value, and convert all plus ('+') characters to spaces. If
957 @param uri a URI-encode encoded URI
958 @param decode_plus determines whether we convert '+' to space.
959 @param size_out if size_out is not NULL, *size_out is set to the size of the
961 @return a newly allocated unencoded URI or NULL on failure
964 char *evhttp_uridecode(const char *uri, int decode_plus,
968 Helper function to parse out arguments in a query.
970 Parsing a URI like
982 @param uri the request URI
984 @return 0 on success, -1 on failure
987 int evhttp_parse_query(const char *uri, struct evkeyvalq *headers);
990 Helper function to parse out arguments from the query portion of an
991 HTTP URI.
1002 @param query_parse the query portion of the URI
1004 @return 0 on success, -1 on failure
1007 int evhttp_parse_query_str(const char *uri, struct evkeyvalq *headers);
1015 * The returned string needs to be freed by the caller.
1030 * Changes the flags set on a given URI. See EVHTTP_URI_* for
1034 void evhttp_uri_set_flags(struct evhttp_uri *uri, unsigned flags);
1037 * been set and the evhttp_uri contains a Relative-Ref. */
1039 const char *evhttp_uri_get_scheme(const struct evhttp_uri *uri);
1045 const char *evhttp_uri_get_userinfo(const struct evhttp_uri *uri);
1048 * The host may either be a regular hostname (conforming to the RFC 3986
1050 * bracketed IPv6 address, or a bracketed 'IP-Future' address.
1052 * Note that having a NULL host means that the URI has no authority
1053 * section, but having an empty-string host means that the URI has an
1059 const char *evhttp_uri_get_host(const struct evhttp_uri *uri);
1060 /** Return the port part of an evhttp_uri, or -1 if there is no port set. */
1062 int evhttp_uri_get_port(const struct evhttp_uri *uri);
1065 const char *evhttp_uri_get_path(const struct evhttp_uri *uri);
1069 const char *evhttp_uri_get_query(const struct evhttp_uri *uri);
1073 const char *evhttp_uri_get_fragment(const struct evhttp_uri *uri);
1076 * Returns 0 on success, -1 if scheme is not well-formed. */
1078 int evhttp_uri_set_scheme(struct evhttp_uri *uri, const char *scheme);
1080 * Returns 0 on success, -1 if userinfo is not well-formed. */
1082 int evhttp_uri_set_userinfo(struct evhttp_uri *uri, const char *userinfo);
1084 * Returns 0 on success, -1 if host is not well-formed. */
1086 int evhttp_uri_set_host(struct evhttp_uri *uri, const char *host);
1087 /** Set the port of an evhttp_uri, or clear the port if port==-1.
1088 * Returns 0 on success, -1 if port is not well-formed. */
1090 int evhttp_uri_set_port(struct evhttp_uri *uri, int port);
1092 * Returns 0 on success, -1 if path is not well-formed. */
1094 int evhttp_uri_set_path(struct evhttp_uri *uri, const char *path);
1097 * Returns 0 on success, -1 if query is not well-formed. */
1099 int evhttp_uri_set_query(struct evhttp_uri *uri, const char *query);
1102 * Returns 0 on success, -1 if fragment is not well-formed. */
1104 int evhttp_uri_set_fragment(struct evhttp_uri *uri, const char *fragment);
1107 * Helper function to parse a URI-Reference as specified by RFC3986.
1109 * This function matches the URI-Reference production from RFC3986,
1114 * and relative-refs like
1118 * Any optional elements portions not present in the original URI are
1119 * left set to NULL in the resulting evhttp_uri. If no port is
1120 * specified, the port is set to -1.
1122 * Note that no decoding is performed on percent-escaped characters in
1123 * the string; if you want to parse them, use evhttp_uridecode or
1126 * Note also that most URI schemes will have additional constraints that
1128 * mailto://www.example.com/cgi-bin/fortune.pl is not a reasonable
1131 * Nevertheless, all of these URLs conform to RFC3986, and this function
1134 * @param source_uri the request URI
1135 * @param flags Zero or more EVHTTP_URI_* flags to affect the behavior
1137 * @return uri container to hold parsed data, or NULL if there is error
1144 /** Tolerate URIs that do not conform to RFC3986.
1146 * Unfortunately, some HTTP clients generate URIs that, according to RFC3986,
1147 * are not conformant URIs. If you need to support these URIs, you can
1148 * do so by passing this flag to evhttp_uri_parse_with_flags.
1152 * <li> Nonconformant URIs are allowed to contain otherwise unreasonable
1163 * Free all memory allocated for a parsed uri. Only use this for URIs
1166 * @param uri container with parsed data
1170 void evhttp_uri_free(struct evhttp_uri *uri);
1173 * Join together the uri parts from parsed data to form a URI-Reference.
1176 * of the evhttp_uri, so the generated string might not be a valid URI
1179 * @param uri container with parsed data
1180 * @param buf destination buffer
1181 * @param limit destination buffer size
1182 * @return an joined uri as string or NULL on error
1186 char *evhttp_uri_join(struct evhttp_uri *uri, char *buf, size_t limit);