You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by sh...@apache.org on 2016/10/11 15:16:31 UTC

[trafficserver] branch master updated: [TS-4457] Via header always reports http1

This is an automated email from the ASF dual-hosted git repository.

shinrich pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/trafficserver.git

The following commit(s) were added to refs/heads/master by this push:
       new  5cc389c   [TS-4457] Via header always reports http1
5cc389c is described below

commit 5cc389cf1c5c21bce371136bf9bf8d534b069080
Author: ericcarlschwartz <es...@gmail.com>
AuthorDate: Thu Sep 29 15:43:54 2016 -0700

    [TS-4457] Via header always reports http1
---
 proxy/http/HttpTransactHeaders.cc | 24 +++++++-----------------
 1 file changed, 7 insertions(+), 17 deletions(-)

diff --git a/proxy/http/HttpTransactHeaders.cc b/proxy/http/HttpTransactHeaders.cc
index db66b4d..be4a927 100644
--- a/proxy/http/HttpTransactHeaders.cc
+++ b/proxy/http/HttpTransactHeaders.cc
@@ -27,6 +27,7 @@
 #include "HTTP.h"
 #include "HdrUtils.h"
 #include "HttpCompat.h"
+#include "HttpSM.h"
 
 #include "I_Machine.h"
 
@@ -812,26 +813,15 @@ HttpTransactHeaders::insert_via_header_in_response(HttpTransact::State *s, HTTPH
   }
 
   char *incoming_via = s->via_string;
-  int scheme         = s->next_hop_scheme;
 
-  ink_assert(scheme >= 0);
-  int scheme_len   = hdrtoken_index_to_length(scheme);
-  int32_t hversion = header->version_get().m_version;
-
-  memcpy(via_string, hdrtoken_index_to_wks(scheme), scheme_len);
-  via_string += scheme_len;
-
-  // Common case (I hope?)
-  if ((HTTP_MAJOR(hversion) == 1) && HTTP_MINOR(hversion) == 1) {
-    memcpy(via_string, "/1.1 ", 5);
-    via_string += 5;
-  } else {
-    *via_string++ = '/';
-    *via_string++ = '0' + HTTP_MAJOR(hversion);
-    *via_string++ = '.';
-    *via_string++ = '0' + HTTP_MINOR(hversion);
+  char const *proto_buf[10]; // 10 seems like a reasonable number of protos to print
+  int retval = s->state_machine->populate_client_protocol(proto_buf, countof(proto_buf));
+  for (int i = 0; i < retval; i++) {
+    memcpy(via_string, proto_buf[i], strlen(proto_buf[i]));
+    via_string += strlen(proto_buf[i]);
     *via_string++ = ' ';
   }
+
   via_string += nstrcpy(via_string, s->http_config_param->proxy_hostname);
   *via_string++ = ' ';
   *via_string++ = '(';

-- 
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>'].