python: Fix bug push response header fields are not passed to callback

This commit is contained in:
Tatsuhiro Tsujikawa 2015-03-06 03:03:55 +09:00
parent 2ed47cdd19
commit bf46539d10
1 changed files with 9 additions and 4 deletions

View File

@ -322,8 +322,6 @@ cdef int client_on_header(cnghttp2.nghttp2_session *session,
logging.debug('client_on_header, type:%s, stream_id:%s', frame.hd.type, frame.hd.stream_id) logging.debug('client_on_header, type:%s, stream_id:%s', frame.hd.type, frame.hd.stream_id)
if frame.hd.type == cnghttp2.NGHTTP2_HEADERS: if frame.hd.type == cnghttp2.NGHTTP2_HEADERS:
if frame.headers.cat == cnghttp2.NGHTTP2_HCAT_REQUEST:
return 0
handler = _get_stream_user_data(session, frame.hd.stream_id) handler = _get_stream_user_data(session, frame.hd.stream_id)
elif frame.hd.type == cnghttp2.NGHTTP2_PUSH_PROMISE: elif frame.hd.type == cnghttp2.NGHTTP2_PUSH_PROMISE:
handler = _get_stream_user_data(session, frame.push_promise.promised_stream_id) handler = _get_stream_user_data(session, frame.push_promise.promised_stream_id)
@ -545,7 +543,7 @@ cdef int client_on_frame_recv(cnghttp2.nghttp2_session *session,
sys.stderr.write(traceback.format_exc()) sys.stderr.write(traceback.format_exc())
return http2._rst_stream(frame.hd.stream_id) return http2._rst_stream(frame.hd.stream_id)
elif frame.hd.type == cnghttp2.NGHTTP2_HEADERS: elif frame.hd.type == cnghttp2.NGHTTP2_HEADERS:
if frame.headers.cat == cnghttp2.NGHTTP2_HCAT_RESPONSE: if frame.headers.cat == cnghttp2.NGHTTP2_HCAT_RESPONSE or frame.headers.cat == cnghttp2.NGHTTP2_HCAT_PUSH_RESPONSE:
handler = _get_stream_user_data(session, frame.hd.stream_id) handler = _get_stream_user_data(session, frame.hd.stream_id)
if not handler: if not handler:
@ -970,7 +968,6 @@ cdef class _HTTP2ClientSessionCore(_HTTP2SessionCoreBase):
handler.method = push_promise.method handler.method = push_promise.method
handler.host = push_promise.host handler.host = push_promise.host
handler.path = push_promise.path handler.path = push_promise.path
handler.headers = push_promise.headers
handler.cookies = push_promise.cookies handler.cookies = push_promise.cookies
handler.stream_id = push_promise.stream_id handler.stream_id = push_promise.stream_id
handler.http2 = self handler.http2 = self
@ -1033,6 +1030,9 @@ if asyncio:
path path
This is a value of :path header field. This is a value of :path header field.
headers
Request header fields
""" """
def __init__(self, http2, stream_id): def __init__(self, http2, stream_id):
@ -1345,6 +1345,11 @@ if asyncio:
path path
This is a value of :path header field. This is a value of :path header field.
headers
Response header fields. There is a special exception. If this
object is passed to push_promise(), this instance variable contains
pushed request header fields.
""" """
def __init__(self, http2=None, stream_id=-1): def __init__(self, http2=None, stream_id=-1):