Commit Graph

200 Commits

Author SHA1 Message Date
Tatsuhiro Tsujikawa 855f39743a Fix crash when indexed repr index=0 2014-05-01 09:06:54 +09:00
Tatsuhiro Tsujikawa 660c536275 Extend namelen and valuelen in nghttp2_nv to size_t 2014-04-30 23:08:34 +09:00
Tatsuhiro Tsujikawa 1b79114d2d Fix compiler warnings 2014-04-30 22:16:21 +09:00
Tatsuhiro Tsujikawa d2e64317ba Code cleanup, include nghttp2_int.h explicitly to ensure debug macro 2014-04-30 22:08:32 +09:00
Alexis La Goutte e00b8f1f73 Fix Dead Store (Dead assignement/Dead increment) warning found by Clang Analyzer 2014-04-30 22:06:42 +09:00
Tatsuhiro Tsujikawa fe6b541233 Handle hd inflate buffer allocation failure 2014-04-30 11:32:05 +09:00
Tatsuhiro Tsujikawa 3b4aedd566 Add HPACK decoder public API 2014-04-29 15:53:46 +09:00
Tatsuhiro Tsujikawa b1722cbe28 Update static table 2014-04-02 01:30:50 +09:00
Tatsuhiro Tsujikawa 7877b676e3 Honor NGHTTP2_NV_FLAG_NO_INDEX in deflater and inflater 2014-04-02 01:25:44 +09:00
Tatsuhiro Tsujikawa 24cb90806d Add flags to nghttp2_nv structure
This is preliminary change for upcoming HPACK updates.  The flags are
used to determine the name/value pair is indexable or not.
2014-04-01 23:17:50 +09:00
Tatsuhiro Tsujikawa ab2dc5967d Replace HTTP/2.0 with HTTP/2 2014-03-30 19:26:37 +09:00
Tatsuhiro Tsujikawa d0fbbe6932 Less cryptic debug message 2014-03-20 00:27:39 +09:00
Tatsuhiro Tsujikawa 142b433533 nghttp2_hd: Treat prematurely ended compressed header block as error properly 2014-03-14 00:52:44 +09:00
Tatsuhiro Tsujikawa 344d663e90 deflate_hd: Fix mishandled error return from emit_indexed_block 2014-03-14 00:25:03 +09:00
Tatsuhiro Tsujikawa d07bb1ddff Rework outbound frame buffers 2014-03-13 22:11:02 +09:00
Tatsuhiro Tsujikawa 3f56c938d8 nghttp2_hd: Use nghttp2_bufs, avoiding realloc() 2014-03-11 21:18:28 +09:00
Tatsuhiro Tsujikawa 358b4386d3 Introduce nghttp2_buf to ease buffer management 2014-03-11 01:47:38 +09:00
Tatsuhiro Tsujikawa 79c5032708 nghttp2_hd: Fix crash with multiple threads execution 2014-03-03 00:53:04 +09:00
Tatsuhiro Tsujikawa 1fee4fd2df nghttp2_hd: Fail inflate immediately if ctx.bad is nonzero
Doing inflation after error produces invalid results, especially, if
it is in NGHTTP2_HD_STATE_READ_INDEX, the inflater->left could be 0,
which causes assertion error.  Add sanity assertion for index
2014-02-26 23:20:52 +09:00
Tatsuhiro Tsujikawa 18357512ed nghttp2_hd: Fix integer decoding bug 2014-02-26 21:44:48 +09:00
Tatsuhiro Tsujikawa fd88c6160d HPACK post -05 updates
* Use 1 Huffman code table for both request and response
* Remove complicated deflater side table size management
* Add encoding context update
* Fix memory leak in inflater
2014-02-13 23:22:52 +09:00
Tatsuhiro Tsujikawa cacf4ecf26 Fix premature header block is not treated as connection error 2014-02-11 16:00:59 +09:00
Tatsuhiro Tsujikawa 9314e30987 Support transmission of CONTINUATION, change nghttp2_frame_hd
The maximum frame size including header block is still limited
to NGHTTP2_HD_MAX_BUFFER_LENGTH, which is 32KB.
2014-01-26 23:10:33 +09:00
Tatsuhiro Tsujikawa e7fc2951b8 nghttp2_hd: Define dedicated struct for HPACK deflater and inflater 2014-01-26 17:53:04 +09:00
Tatsuhiro Tsujikawa 8317559090 nghttp2_hd: Implement stream header inflater
This stream inflater can inflate incoming header block in streaming
fashion. Currently, we buffer up single name/value pair, but we chose
far more smaller buffer size than HTTP/2 frame size.
2014-01-25 18:24:15 +09:00
Tatsuhiro Tsujikawa 201ab1a140 nghttp2_hd: Adjust maximum size to index based on table size 2014-01-21 21:49:53 +09:00
Tatsuhiro Tsujikawa 073e6d3a01 nghttp2_hd: Remove unused variables 2014-01-17 09:36:38 +09:00
Tatsuhiro Tsujikawa 0e4b3d435e Emit header name/value pair using callback functions
Now, in nghttp2_on_frame_recv_callback, nva and nvlen in
HEADERS and PUSH_PROMISE frames are always NULL and 0 respectively.
The header name/value pairs are emitted successive
nghttp2_on_header_callback functions. The end of header fields are
signaled with nghttp2_on_end_headers_callback function.

Since NGHTTP2_ERR_PAUSE for nghttp2_on_frame_recv_callback is
introduced to handle header block, it is now deprecated.
Instead, nghttp2_on_header_callback can be paused using
NGHTTP2_ERR_PAUSE.
2014-01-17 01:49:43 +09:00
Tatsuhiro Tsujikawa 63e7b21b35 nghttp2_hd: Fix lower bound search in static table 2014-01-08 21:32:39 +09:00
Tatsuhiro Tsujikawa 0fb4d32d6a nghttp2_hd: Binary search static table 2014-01-07 23:41:09 +09:00
Tatsuhiro Tsujikawa 468d0fccd3 nghttp2_hd: Use hash to speed up name/value pair search 2014-01-07 22:43:34 +09:00
Tatsuhiro Tsujikawa d703197a50 nghttp2_hd: Mitigate timing attack 2014-01-07 21:51:48 +09:00
Tatsuhiro Tsujikawa 9eb031ce83 nghttp2_hd: Avoid nghttp2_hd_huff_decode_count
Huffman decoding is costly. It is faster to do geometric realloc
than calling nghttp2_hd_huff_decode_count to know the length in
advance.
2014-01-07 21:44:56 +09:00
Tatsuhiro Tsujikawa 4ac1652c70 nghttp2_hd: Remove invalid nghttp2_downcase call 2014-01-07 21:18:45 +09:00
Tatsuhiro Tsujikawa dfcdea894b Move header name/value pair validation to on_*_received functions 2013-12-25 23:38:55 +09:00
Tatsuhiro Tsujikawa 7c4dbb6ffc nghttp2_hd: Don't malloc if huffman encoded string has 0 length 2013-12-19 23:19:14 +09:00
Tatsuhiro Tsujikawa 5ca0cfa018 nghttp2_hd: Search hd table once 2013-12-18 21:45:15 +09:00
Tatsuhiro Tsujikawa 01266182e9 nghttp2_hd: Match deflate_hd_tablelen to hd_table.len on decoder side 2013-12-17 21:39:21 +09:00
Tatsuhiro Tsujikawa 595493a0ec Add debug output in nghttp2_hd 2013-12-16 23:54:20 +09:00
Tatsuhiro Tsujikawa e61876ccbd nghttp2_hd: Provide dedicated function to enable no reference set feature 2013-12-14 18:48:41 +09:00
Tatsuhiro Tsujikawa e5e4fc9d14 nghttp2_hd: Define some headers not for indexing based on our research 2013-11-19 21:41:02 +09:00
Tatsuhiro Tsujikawa 8915e91b17 nghttp2_hd: Enlarge buffers used in inflation process dynamically 2013-11-16 23:13:46 +09:00
Tatsuhiro Tsujikawa 3d863ed254 nghttp2_hd: Clear reference set with index 0 2013-11-16 17:05:18 +09:00
Tatsuhiro Tsujikawa 94ec4dbe42 nghttpd_hd: Update static table and use 1-based index
The specification now says that index to the header table entry is
1-based. Since 0-based index is very handy to access arrays, we
internally uses 0-based index. We just convert it to 1-based when
we emit to the block and convert 1-based to 0-based on decoding.
2013-11-16 16:18:44 +09:00
Tatsuhiro Tsujikawa 40347487c9 Don't sort headers in library code
Remove sorting headers from library code. The application must sort
them if necessary. nghttpx and nghttpd do the sorting of the headers
in stable way if names are equal.
2013-11-13 23:56:02 +09:00
Tatsuhiro Tsujikawa ac354d3b91 Fix compile error with --enable-maintainer-mode 2013-11-08 01:35:15 +09:00
Tatsuhiro Tsujikawa 2d08d30409 nghttp2_hd: Fix crash 2013-11-03 17:46:10 +09:00
Tatsuhiro Tsujikawa b0f76773e1 nghttp2_hd: Use defalte_hd_table_bufsize for decoder as well 2013-10-31 01:51:16 +09:00
Tatsuhiro Tsujikawa c8a9f8d312 nghttp2_hd: Fix crash on fail 2013-10-31 01:26:37 +09:00
Tatsuhiro Tsujikawa 6c99ff12c9 nghttp2_hd: Rename local as deflate 2013-10-29 00:42:08 +09:00
Tatsuhiro Tsujikawa 67ce60544e Change maximum frame length to 16383 2013-10-27 21:17:09 +09:00
Tatsuhiro Tsujikawa 22df6f4190 nghttp2_hd: Fix bug on local_hd_table_bufsize_max > hd_table_bufsize_max 2013-10-26 23:30:48 +09:00
Tatsuhiro Tsujikawa cbdd44c4ae nghttp2_hd: Implement local header table size limit for encoder 2013-10-26 18:49:23 +09:00
Tatsuhiro Tsujikawa abfc00983d nghttp2_hd: Fix memory leak and bad free 2013-10-24 23:49:37 +09:00
Tatsuhiro Tsujikawa 0c3cb104e9 nghttp2_hd: Share static table globally 2013-10-24 22:09:40 +09:00
Tatsuhiro Tsujikawa 5a81e03497 nghttp2_hd: Add static table entry to dynamic table on emission 2013-10-24 21:52:02 +09:00
Tatsuhiro Tsujikawa d5ccc89fc4 Update huffman table and static table
Use huffman table in https://github.com/grmocg/httpbis-header-compression
2013-10-21 23:56:14 +09:00
Tatsuhiro Tsujikawa 9e50ae46d9 nghttp_hd: Use NGHTTP2_HD_SIDE_{REQUEST,RESPONSE} instead of {CLIENT,SERVER}
This change conveys better notion about compression context.
2013-10-21 00:44:39 +09:00
Tatsuhiro Tsujikawa 8ef134a702 nghttp_hd: Refactor emit_indname_block and emit_newname_block 2013-10-21 00:22:14 +09:00
Tatsuhiro Tsujikawa 28aea5c6b7 nghttp_hd: Use huffman encoding only when it is usable
We use huffman encoding only when its encoded length is strictly less
than the original length.
As noted in the HPACK draft, the length of name/value is now 7-bit
prefix and its MSB is 1 if the following string is huffman encoded.
2013-10-20 23:59:15 +09:00
Tatsuhiro Tsujikawa a658f1367e encode_length: Or-ing first byte with prefix mask
So that we can preserve leading bits.
2013-10-20 16:28:52 +09:00
Tatsuhiro Tsujikawa 4e4fab01b1 Merge branch 'master' into hpack-exp
Conflicts:
	lib/nghttp2_hd.c
2013-10-18 20:06:36 +09:00
Tatsuhiro Tsujikawa 7b87d71121 nghttp2_hd: Fix missing return value handling 2013-10-18 19:48:15 +09:00
Tatsuhiro Tsujikawa 7bd145fd23 Fix out of bound array access in decode_length 2013-10-18 19:30:04 +09:00
Tatsuhiro Tsujikawa f7389ff2e6 Revert 622b05aa31
It turns out that 0-bit prefix is wrong, and the author now
clearly stated that the intention is 8-bit prefix for 8+ fields.
2013-10-18 19:28:01 +09:00
Tatsuhiro Tsujikawa a2735ed025 Fix leak on failure 2013-10-16 00:12:33 +09:00
Tatsuhiro Tsujikawa ed43635c7b Updated latest initial static header table 2013-10-16 00:09:00 +09:00
Tatsuhiro Tsujikawa 50cdcca911 Implement static Huffman for header compression
The current implementation uses Huffman code tables described
in http://tools.ietf.org/html/draft-rpeon-httpbis-header-compression-03
2013-10-15 23:55:12 +09:00
Tatsuhiro Tsujikawa 5b1fc35e82 Make max header table size configurable 2013-10-13 19:24:21 +09:00
Tatsuhiro Tsujikawa 6d7bcabe4c Don't allocate name when indexing with name in static table 2013-10-12 22:56:29 +09:00
Tatsuhiro Tsujikawa 8cf3731802 Experiment HPACK with upcoming changes
* remove substitution
* reversed insertion and removal from header table
* unified initial static table
2013-10-12 21:49:01 +09:00
Tatsuhiro Tsujikawa 622b05aa31 Fix HPACK using 0-bit prefix instead of 8-bits 2013-10-10 23:58:33 +09:00
Tatsuhiro Tsujikawa 3390c2356e Update doc 2013-09-07 15:28:43 +09:00
Tatsuhiro Tsujikawa 4db8338012 Fix resource leak 2013-09-07 01:45:54 +09:00
Tatsuhiro Tsujikawa 4dcf9ad4f2 Make hd encoder ordering aware and one-pass
The encoder algorithm is simplified and it now preserves ordering
of the headers. It also becomes one-pass encoder.
2013-09-06 21:53:28 +09:00
Tatsuhiro Tsujikawa 16076cbc2f Increase NGHTTP2_HD_MAX_ENTRY_SIZE to 3072 2013-09-06 00:17:46 +09:00
Tatsuhiro Tsujikawa 1723912f35 Call nghttp2_hd_end_headers from nghttp2_hd_deflate_hd 2013-09-03 21:41:22 +09:00
Tatsuhiro Tsujikawa 83b0c89e3c Handle indexing entry greater than header table limit without error 2013-08-28 23:16:23 +09:00
Tatsuhiro Tsujikawa 4fe056d208 nghttp2_hd.c: Use rv != 0 instead of rv < 0 2013-08-28 21:35:18 +09:00
Tatsuhiro Tsujikawa f0ef6e980f Refactor nghttp2_hd_inflate_hd 2013-08-28 21:33:57 +09:00
Tatsuhiro Tsujikawa 82b9f78fc7 Check incoming header field name strictly
The validation rule is described in
http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-02#section-4.1.2
2013-08-25 17:39:29 +09:00
Tatsuhiro Tsujikawa 091f38a99d Revise common header processing
Instead of emitting common headers on decoder side, encoder
now keeps track of removed common headers and encode it
as necessary.
2013-08-24 22:58:26 +09:00
Tatsuhiro Tsujikawa 005e60a5ed Rework header compression 2013-08-23 23:38:28 +09:00
Tatsuhiro Tsujikawa 93e5b9e562 Fix bug common header disappear if it is evicted 2013-08-23 03:45:26 +09:00
Tatsuhiro Tsujikawa 346fafde3f Implement draft-ietf-httpbis-header-compression-02 2013-08-23 03:33:05 +09:00
Tatsuhiro Tsujikawa 55b074e96e Rename NGHTTP2_MAX_FRAME_SIZE as NGHTTP2_MAX_FRAME_LENGTH 2013-08-06 21:59:41 +09:00
Tatsuhiro Tsujikawa 7021a9fc5e Incremental indexing only when the entry size if less than threshold 2013-07-27 20:48:04 +09:00
Tatsuhiro Tsujikawa f74674aa7f Fix header compression (again) 2013-07-27 19:23:05 +09:00
Tatsuhiro Tsujikawa ddd04e8ced Fix header compression bug, and perform always incremental indexing 2013-07-27 00:58:38 +09:00
Tatsuhiro Tsujikawa e496800cb7 Fix header compression bug 2013-07-26 01:34:28 +09:00
Tatsuhiro Tsujikawa 321136b042 nghttp2_hd: Don't malloc if namelen/valuelen are zero 2013-07-23 23:10:53 +09:00
Tatsuhiro Tsujikawa 3c9e31da87 Don't substitute if same indexed header field name is already in working set 2013-07-23 02:52:08 +09:00
Tatsuhiro Tsujikawa 68afda92ac Cleanup 2013-07-20 01:28:52 +09:00
Tatsuhiro Tsujikawa b92b49f882 Cleanup 2013-07-20 01:27:26 +09:00
Tatsuhiro Tsujikawa 9c58004a86 Cleanup 2013-07-20 01:24:34 +09:00
Tatsuhiro Tsujikawa e92b74d66e Use substitution as long as no eviction is required 2013-07-20 01:19:00 +09:00
Tatsuhiro Tsujikawa aa87130711 Fix uninitialized nghttp2_hd_ws_entry index 2013-07-20 01:02:01 +09:00
Tatsuhiro Tsujikawa 00b2d06850 Refactor nghttp2_hd 2013-07-20 01:02:01 +09:00
Tatsuhiro Tsujikawa 61bf7c6b02 Integrate new header compression 2013-07-20 00:08:14 +09:00
Tatsuhiro Tsujikawa 45c2245bfb Implement header compression draft 01 2013-07-19 16:50:31 +09:00