From 6e7d0286e36c8ab9d28f52745012ea90849a659d Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sat, 10 May 2014 23:45:05 +0900 Subject: [PATCH] python: Utilize return value of nghttp2_submit_push_promise --- python/nghttp2.pyx | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/python/nghttp2.pyx b/python/nghttp2.pyx index 671cf556..faa2ed2e 100644 --- a/python/nghttp2.pyx +++ b/python/nghttp2.pyx @@ -425,7 +425,6 @@ cdef int server_on_frame_send(cnghttp2.nghttp2_session *session, if not handler: return 0 - handler.stream_id = frame.push_promise.promised_stream_id http2.send_response(handler) elif frame.hd.type == cnghttp2.NGHTTP2_SETTINGS: if (frame.hd.flags & cnghttp2.NGHTTP2_FLAG_ACK) == 0: @@ -613,20 +612,24 @@ cdef class _HTTP2SessionCore: def push(self, handler, promised_handler): cdef cnghttp2.nghttp2_nv *nva cdef size_t nvlen + cdef int32_t promised_stream_id self.handlers.add(promised_handler) nva = NULL nvlen = _make_nva(&nva, promised_handler.headers) - rv = cnghttp2.nghttp2_submit_push_promise(self.session, - cnghttp2.NGHTTP2_FLAG_NONE, - handler.stream_id, - nva, nvlen, - promised_handler) - if rv != 0: + promised_stream_id = cnghttp2.nghttp2_submit_push_promise\ + (self.session, + cnghttp2.NGHTTP2_FLAG_NONE, + handler.stream_id, + nva, nvlen, + promised_handler) + if promised_stream_id < 0: raise Exception('nghttp2_submit_push_promise failed: {}'.format\ - (_strerror(rv))) + (_strerror(promised_stream_id))) + + promised_handler.stream_id = promised_stream_id def _rst_stream(self, stream_id, error_code=cnghttp2.NGHTTP2_INTERNAL_ERROR):