Commit graph

42 commits

Author SHA1 Message Date
Mark Ellzey
28710f8401 Added htparser_get_content_pending for fetching bytes left to process. 2012-12-26 12:35:48 -05:00
Mark Ellzey
bb6cdac900 get_content_len now returns non-modified content_len var 2012-12-26 12:28:20 -05:00
Mark Ellzey
227695505a Merge branch 'develop' into feature/sodabrew_client 2012-12-07 16:46:48 -05:00
Mark Ellzey
9d8e243235 parser fixes / deal with paused responses better.
- parser: in some cases, the next state was not being set if a user callback
  returned a non 0.

- evhtp: check for a paused request, no matter if the parser failed.
2012-12-06 12:28:28 -05:00
Mark Ellzey
d5c640a046 Added htparser test for empty header keys. 2012-12-06 07:22:11 -05:00
Mark Ellzey
59de92ab84 Fixes for multiple requests, new htparse tests
- Due to some changes made recently, when the htparser state went back to the
  beginning after a request had been processed, some variables were not being
  reset. When multiple requests exist, the prior request could have written
  something the current request doesn't use. This resulted in corrupted data.

  The fix was to simply reset those variables each time the state goes to start.

- Rewrote the test.c app to be more flexible and verbose on output.
2012-11-28 14:38:42 -05:00
Mark Ellzey
93e4f0f3f4 Changed host_ipv6_done state to host_done 2012-11-28 11:35:14 -05:00
Marcus Sundberg
622256b0ef (htparse): Add support for CONNECT and PATCH methods. 2012-11-28 11:28:57 -05:00
Marcus Sundberg
6f1b93f207 (htparse): Avoid memset()ing entire parse buffer on init.
When profiling a libevhtp application this unnecessary memset() takes
a very noticable amount of time.
2012-11-28 11:28:50 -05:00
Marcus Sundberg
9f53ee55d7 (htparse): Fix parsing of ftp and nfs schemes. 2012-11-28 11:28:43 -05:00
Marcus Sundberg
b495e818aa (htparse): Handle literal IPv6 addresses in URIs.
IPv6 addresses are enclosed in brackets when used in an URI.
2012-11-28 11:28:38 -05:00
Marcus Sundberg
1f60434a7f (htparse): Use correct arguments to hook_port_run(). 2012-11-28 11:28:32 -05:00
Marcus Sundberg
657fe3b3e5 (htparse): Properly handle abolute-URI with empty path.
Set the path that will be used when calling hook_path_run() and
hook_uri_run() in s_after_slash_in_uri state to "/", not " ".
Also handle empty path when a port is specified in the host part.
2012-11-28 11:28:27 -05:00
Marcus Sundberg
0e7bdcd9e5 (htparse): Handle query parameters according to RFC 3986.
The query component is indicated by the first question mark ("?")
character and terminated by a number sign ("#") character or by the
end of the URI.

The old code started the query component at the *last* question mark.
2012-11-28 11:28:20 -05:00
Marcus Sundberg
51f78e4940 (htparse): Use correct length parameter when calling hooks. 2012-11-28 11:28:14 -05:00
Marcus Sundberg
8aaa419676 (htparse): Use correct arguments to hook_path_run(). 2012-11-28 11:28:08 -05:00
Marcus Sundberg
1bb641f6cc (htparse): Properly propagate errors from hook_on_hdrs_begin_run()
Previously returning an error from evhtp_hook_on_headers_start() did
not terminate the connection.
2012-11-28 11:28:00 -05:00
Mark Ellzey
c1f52163e5 Add documentation on fallthrough state for method proto. 2012-11-26 11:51:37 -05:00
Mark Ellzey
f652e60e9b Merge remote-tracking branch 'sodabrew/feature/evhtp_client' into feature/sodabrew_client
Conflicts:
	.gitignore
	evhtp.c
	evhtp.h
2012-11-26 11:05:30 -05:00
Mark Ellzey
79ec9bd610 Merge pull request #50 from jedisct1/parse-requests-with-hosts-and-empty-path
Accept requests like <method> <protocol>://<host> <http version>
2012-11-26 07:57:19 -08:00
Mark Ellzey
f68b55027d derp 2012-11-20 14:58:49 -05:00
Mark Ellzey
60b35029c0 Renaming evhtp_hook_generic_cb to evhtp_hook, more ISO compliance. 2012-10-22 14:23:39 -04:00
Mark Ellzey
325c5c7aaa add upport multiline header values. 2012-10-11 13:05:21 -04:00
Mark Ellzey
d51b526ee8 Fix issue 53, error on LF without CR's 2012-09-20 17:03:26 -04:00
Mark Ellzey
8ff9cf34e1 Fixed issue with query argument decoding. 2012-09-07 18:49:52 -04:00
Mark Ellzey
7ec160fc60 Add support for empty header values. 2012-08-16 12:27:06 -04:00
Mark Ellzey
87fb859961 Fix for state set override for headers. 2012-08-13 18:13:38 -04:00
Frank Denis
9d14692197 Accept requests like <method> <protocol>://<host> <http version>
That is, without an extra / after the host. Consider the path as /
and keep parsing the line instead of reverting to HTTP 0.9
2012-07-17 15:27:50 -07:00
Aaron Stone
b2d5f72d34 Merge branch 'master' into feature/evhtp_client
Conflicts:
	CMakeLists.txt
	evhtp.c
	evhtp.h
	htparse/htparse.h
	test.c
2012-07-03 12:02:58 -07:00
Mark Ellzey
2f774289be hook_on_hdrs_complete runs before last LF 2012-06-18 12:12:29 -04:00
Mark Ellzey
caddf104f4 Optimizations. 2012-06-14 15:57:05 -04:00
Mark Ellzey
500d3d8808 Initial hack for non SSL vhosts. 2012-06-12 17:54:50 -04:00
Mark Ellzey
e6155d8872 Bugfixes, additions, cleanup, see full commit msg.
* evhtp_send_reply_end bugfix: evhtp_send_reply_end() would set the request as
  finished and then call bufferevent_flush(). The assumption here was bufferevent_flush()
  actually does something, which in reality isn't the case:

  bufferevent_sock    = be_socket_flush(...) { return 0; }
  bufferevent_openssl = be_openssl_flush(...) { return 0; }

  My dumb expectation was the writecb would get called on a flush, so instead
  send_reply_end() will now call the writecb directly (this function makes sure
  all data has been sent and the request is finished, etc).

* _evhtp_accept_cb() will now check the return status of evthr_pool_defer, which
  may return a RETRY. In this case it is assumed that the evthr is way too busy
  and will drop the connection. In the future we may want to create a retry
  mechanism to avoid dropped connections. Reasoning for this is if a evthr_defer
  fails, a connection will be in limbo, and never accepted().

* Fixed minor bug in the http parser for reply status code errors.

* Made evhtp_unset_hook() public.

* Made evhtp_unset_all_hooks() public.
2012-04-04 13:18:39 -04:00
Mark Ellzey
4a9eefb6fb Added total bytes read function in htparser. 2012-03-08 13:20:25 -05:00
Mark Ellzey
a52d6afad1 Merge branch 'ahochhaus' into develop
Conflicts:
	evhtp.h
2011-12-27 14:48:35 -05:00
Andy Hochhaus
af2a0dd180 Fix C++/clang++ build. 2011-12-27 12:50:56 -06:00
Mark Ellzey
137aa19988 Added htparser_set_(major|minor). fixed edgecase where major/minor is not yet set. 2011-12-27 11:36:01 -05:00
Mark Ellzey
7076b8ee1a added on_headers_start hook (before header parsing, post requestline parsing). 2011-12-27 11:29:25 -05:00
Nick Mathewson
7d0084e5d8 Eliminate use of ctype.h
The ctype.h functions, unfortunately, depend on the current locale.
This makes them unsuitable for handling network data, since they can
tell you different answers depending on what locale is set.

This patch also changes the behavior of % in queries in evhtp.c.
Previously, any alphanumeric, non-punctuation character was
acceptable.  Now, it's only hex characters.  If we should change it
back for some reason, there is just one function to edit.
2011-12-15 00:00:37 -05:00
Nick Mathewson
b0c226765b Detect non-ascii hosts and refuse to build on them
The htparse library makes some assumptions about characters that are
not true for non-ascii-based system.  (For example, that all
upper-case letters are numerically between 'A' and 'Z'; or that
(int)'A' is the same as the encoding of 'h' on the wire.)  This is
always true in practice, except for some really horrible places we
will never want to build. But in theory, C allows (int)'A' to be
basically anything.  So let's put our pedantic hats on briefly and
detect non-ASCII environments, if only to give an error.
2011-12-14 23:59:04 -05:00
Mark Ellzey
a3487fd24d Fixed issue with OPTIONS requests. 2011-12-12 13:44:44 -05:00
Mark Ellzey
bf2e43a51a Moving libhtparse to just htparse 2011-11-23 12:55:04 -05:00