trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shinr...@apache.org
Subject trafficserver git commit: TS-3415: H2 sending FIN stream too early
Date Wed, 04 Mar 2015 16:56:36 GMT
Repository: trafficserver
Updated Branches:
  refs/heads/master 9f7cdf8d1 -> 789d2946c


TS-3415: H2 sending FIN stream too early


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/789d2946
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/789d2946
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/789d2946

Branch: refs/heads/master
Commit: 789d2946cb903bbf089b402fee34d65f71cecec7
Parents: 9f7cdf8
Author: Ryo Okubo <rokubo@yahoo-corp.jp>
Authored: Wed Mar 4 10:49:34 2015 -0600
Committer: shinrich <shinrich@yahoo-inc.com>
Committed: Wed Mar 4 10:55:29 2015 -0600

----------------------------------------------------------------------
 CHANGES                             |  2 ++
 proxy/http2/HTTP2.cc                | 30 +++++++++++++-----------------
 proxy/http2/HTTP2.h                 |  3 ---
 proxy/http2/Http2ConnectionState.cc |  7 +++----
 4 files changed, 18 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/789d2946/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 93feb3b..005351a 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.3.0
 
+  *) [TS-3415] Http/2 sending FIN stream too early.
+
   *) [TS-3414] Add new TS API TSHttpTxnOutgoingAddrGet 
 
   *) [TS-3421] Add a "-t range" option for proxyauth plugin, which similar to

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/789d2946/proxy/http2/HTTP2.cc
----------------------------------------------------------------------
diff --git a/proxy/http2/HTTP2.cc b/proxy/http2/HTTP2.cc
index 5db603d..530186b 100644
--- a/proxy/http2/HTTP2.cc
+++ b/proxy/http2/HTTP2.cc
@@ -542,20 +542,6 @@ convert_from_2_to_1_1_header(HTTPHdr* headers)
   return PARSE_DONE;
 }
 
-void
-convert_headers_from_1_1_to_2(HTTPHdr* in)
-{
-  // Intermediaries SHOULD also remove other connection-
-  // specific header fields, such as Keep-Alive, Proxy-Connection,
-  // Transfer-Encoding and Upgrade, even if they are not nominated by
-  // Connection.
-  in->field_delete(MIME_FIELD_CONNECTION, MIME_LEN_CONNECTION);
-  in->field_delete(MIME_FIELD_KEEP_ALIVE, MIME_LEN_KEEP_ALIVE);
-  in->field_delete(MIME_FIELD_PROXY_CONNECTION, MIME_LEN_PROXY_CONNECTION);
-  in->field_delete(MIME_FIELD_TRANSFER_ENCODING, MIME_LEN_TRANSFER_ENCODING);
-  in->field_delete(MIME_FIELD_UPGRADE, MIME_LEN_UPGRADE);
-}
-
 int64_t
 http2_write_psuedo_headers(HTTPHdr* in, uint8_t* out, uint64_t out_len, Http2DynamicTable&
/* dynamic_table */)
 {
@@ -615,7 +601,19 @@ http2_write_header_fragment(HTTPHdr* in, MIMEFieldIter& field_iter,
uint8_t* out
 
   // Set mime headers
   cont = false;
-  while (field) {
+  for (; field != NULL; field = in->iter_get_next(&field_iter)) {
+
+    // Intermediaries SHOULD remove connection-specific header fields.
+    int name_len;
+    const char* name = field->name_get(&name_len);
+    if ((name_len == MIME_LEN_CONNECTION        && strncasecmp(name, MIME_FIELD_CONNECTION,
name_len) == 0) ||
+        (name_len == MIME_LEN_KEEP_ALIVE        && strncasecmp(name, MIME_FIELD_KEEP_ALIVE,
name_len) == 0) ||
+        (name_len == MIME_LEN_PROXY_CONNECTION  && strncasecmp(name, MIME_FIELD_PROXY_CONNECTION,
name_len) == 0) ||
+        (name_len == MIME_LEN_TRANSFER_ENCODING && strncasecmp(name, MIME_FIELD_TRANSFER_ENCODING,
name_len) == 0) ||
+        (name_len == MIME_LEN_UPGRADE           && strncasecmp(name, MIME_FIELD_UPGRADE,
name_len) == 0)) {
+      continue;
+    }
+
     MIMEFieldIter current_iter = field_iter;
     do {
       MIMEFieldWrapper header(field, in->m_heap, in->m_http->m_fields_impl);
@@ -632,7 +630,6 @@ http2_write_header_fragment(HTTPHdr* in, MIMEFieldIter& field_iter,
uint8_t* out
       }
       p += len;
     } while (field->has_dups() && (field = field->m_next_dup) != NULL);
-    field = in->iter_get_next(&field_iter);
   }
 
   // Parsing all headers is done
@@ -960,7 +957,6 @@ REGRESSION_TEST(HPACK_Encode)(RegressionTest * t, int, int *pstatus)
     }
 
     memset(buf, 0, BUFSIZE_FOR_REGRESSION_TEST);
-    convert_headers_from_1_1_to_2(headers);
     uint64_t buf_len = BUFSIZE_FOR_REGRESSION_TEST;
     int64_t len = http2_write_psuedo_headers(headers, buf, buf_len, dynamic_table);
     buf_len -= len;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/789d2946/proxy/http2/HTTP2.h
----------------------------------------------------------------------
diff --git a/proxy/http2/HTTP2.h b/proxy/http2/HTTP2.h
index 555186d..da490fc 100644
--- a/proxy/http2/HTTP2.h
+++ b/proxy/http2/HTTP2.h
@@ -318,9 +318,6 @@ http2_parse_header_fragment(HTTPHdr *, IOVec, Http2DynamicTable&,
bool);
 MIMEParseResult
 convert_from_2_to_1_1_header(HTTPHdr *);
 
-void
-convert_headers_from_1_1_to_2(HTTPHdr*);
-
 int64_t
 http2_write_psuedo_headers(HTTPHdr*, uint8_t*, uint64_t, Http2DynamicTable&);
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/789d2946/proxy/http2/Http2ConnectionState.cc
----------------------------------------------------------------------
diff --git a/proxy/http2/Http2ConnectionState.cc b/proxy/http2/Http2ConnectionState.cc
index 7f02c45..7f8ebbe 100644
--- a/proxy/http2/Http2ConnectionState.cc
+++ b/proxy/http2/Http2ConnectionState.cc
@@ -880,15 +880,14 @@ Http2ConnectionState::send_headers_frame(FetchSM *fetch_sm)
   Http2Stream* stream = static_cast<Http2Stream*>(fetch_sm->ext_get_user_data());
   HTTPHdr* resp_header = reinterpret_cast<HTTPHdr*>(fetch_sm->resp_hdr_bufp());
 
-  // Convert header fields to HTTP/2 format
-  convert_headers_from_1_1_to_2(resp_header);
-
   // Write psuedo headers
   payload_length += http2_write_psuedo_headers(resp_header, payload_buffer,
                                                buf_len, *(this->remote_dynamic_table));
 
   // If response body is empry, set END_STREAM flag to HEADERS frame
-  if (resp_header->get_content_length() == 0) {
+  // Must check to ensure content-length is there.  Otherwise the value defaults to 0
+  if (resp_header->presence(MIME_PRESENCE_CONTENT_LENGTH) && 
+      resp_header->get_content_length() == 0) {
     flags |= HTTP2_FLAGS_HEADERS_END_STREAM;
   }
 


Mime
View raw message