Commit 7048c565 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

python: Update to latest nghttp2_hd spec

parent 707a0b41
......@@ -86,10 +86,10 @@ cdef extern from 'nghttp2_hd.h':
nghttp2_nv *nva, size_t nvlen)
ssize_t nghttp2_hd_inflate_hd(nghttp2_hd_context *inflater,
nghttp2_nv **nva_ptr,
nghttp2_nv *nv_out, int *final,
uint8_t *input, size_t inlen)
int nghttp2_hd_end_headers(nghttp2_hd_context *deflater_or_inflater)
int nghttp2_hd_inflate_end_headers(nghttp2_hd_context *inflater)
nghttp2_hd_entry* nghttp2_hd_table_get(nghttp2_hd_context *context,
size_t index)
......@@ -199,19 +199,24 @@ cdef class HDInflater(_HDContextBase):
byte string (not unicode string).
'''
cdef cnghttp2.nghttp2_nv *nva
cdef cnghttp2.nghttp2_nv nv
cdef int final
cdef ssize_t rv
rv = cnghttp2.nghttp2_hd_inflate_hd(&self._ctx, &nva,
data, len(data))
if rv < 0:
raise Exception(_strerror(rv))
try:
res = [(nva[i].name[:nva[i].namelen],
nva[i].value[:nva[i].valuelen]) for i in range(rv)]
finally:
cnghttp2.nghttp2_nv_array_del(nva)
cnghttp2.nghttp2_hd_end_headers(&self._ctx)
cdef uint8_t *buf = data
cdef size_t buflen = len(data)
res = []
while True:
rv = cnghttp2.nghttp2_hd_inflate_hd(&self._ctx, &nv, &final,
buf, buflen)
if rv < 0:
raise Exception(_strerror(rv))
if final:
break
buf += rv
buflen -= rv
# may throw
res.append((nv.name[:nv.namelen], nv.value[:nv.valuelen]))
cnghttp2.nghttp2_hd_inflate_end_headers(&self._ctx)
return res
cdef _strerror(int liberror_code):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment