From 6404896d8cb100e1fa8ed96166a02fc660b2f1a6 Mon Sep 17 00:00:00 2001
From: Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>
Date: Thu, 8 May 2014 00:20:05 +0900
Subject: [PATCH] http2: Compile with latest nghttp2

Now nghttp2_submit_request returns assigned stream ID, we don't have
to check stream ID using before_stream_send_callback.  The
adjust_priority_callback was removed.
---
 lib/http2.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/lib/http2.c b/lib/http2.c
index d4bc82afab..3ee99e20ba 100644
--- a/lib/http2.c
+++ b/lib/http2.c
@@ -270,15 +270,9 @@ static int before_frame_send(nghttp2_session *session,
                              void *userp)
 {
   struct connectdata *conn = (struct connectdata *)userp;
-  struct http_conn *c = &conn->proto.httpc;
   (void)session;
   (void)frame;
   infof(conn->data, "before_frame_send() was called\n");
-  if(frame->hd.type == NGHTTP2_HEADERS &&
-     frame->headers.cat == NGHTTP2_HCAT_REQUEST) {
-    /* Get stream ID of our request */
-    c->stream_id = frame->hd.stream_id;
-  }
   return 0;
 }
 static int on_frame_send(nghttp2_session *session,
@@ -400,7 +394,6 @@ static const nghttp2_session_callbacks callbacks = {
   on_header              /* nghttp2_on_header_callback */
 #if NGHTTP2_VERSION_NUM >= 0x000400
   , NULL                 /* nghttp2_select_padding_callback */
-  , NULL                 /* nghttp2_adjust_priority_callback */
 #endif
 };
 
@@ -639,6 +632,8 @@ static ssize_t http2_send(struct connectdata *conn, int sockindex,
   char *hdbuf = (char*)mem;
   char *end;
   nghttp2_data_provider data_prd;
+  int32_t stream_id;
+
   (void)sockindex;
 
   infof(conn->data, "http2_send len=%zu\n", len);
@@ -744,20 +739,23 @@ static ssize_t http2_send(struct connectdata *conn, int sockindex,
   case HTTPREQ_PUT:
     data_prd.read_callback = data_source_read_callback;
     data_prd.source.ptr = NULL;
-    rv = nghttp2_submit_request(httpc->h2, NULL, nva, nheader, &data_prd,
-                                NULL);
+    stream_id = nghttp2_submit_request(httpc->h2, NULL, nva, nheader,
+                                       &data_prd, NULL);
     break;
   default:
-    rv = nghttp2_submit_request(httpc->h2, NULL, nva, nheader, NULL, NULL);
+    stream_id = nghttp2_submit_request(httpc->h2, NULL, nva, nheader,
+                                       NULL, NULL);
   }
 
   Curl_safefree(nva);
 
-  if(rv != 0) {
+  if(stream_id < 0) {
     *err = CURLE_SEND_ERROR;
     return -1;
   }
 
+  httpc->stream_id = stream_id;
+
   rv = nghttp2_session_send(httpc->h2);
 
   if(rv != 0) {
-- 
GitLab