You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficserver.apache.org by shukitchan <gi...@git.apache.org> on 2017/03/01 08:02:18 UTC

[GitHub] trafficserver pull request #1520: Report protocol in request via header

GitHub user shukitchan opened a pull request:

    https://github.com/apache/trafficserver/pull/1520

    Report protocol in request via header

    See #1506

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/shukitchan/trafficserver issue-1506

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/trafficserver/pull/1520.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #1520
    
----
commit dbfb804e78608a29c21270b9f447ee690b8ea096
Author: Kit Chan <ki...@apache.org>
Date:   2017-03-01T07:27:37Z

    report protocol in request via header

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver pull request #1520: Report protocol in request via header

Posted by maskit <gi...@git.apache.org>.
Github user maskit commented on a diff in the pull request:

    https://github.com/apache/trafficserver/pull/1520#discussion_r104074965
  
    --- Diff: proxy/http/HttpTransactHeaders.cc ---
    @@ -741,26 +741,14 @@ HttpTransactHeaders::insert_via_header_in_request(HttpTransact::State *s, HTTPHd
       }
     
       char *incoming_via = s->via_string;
    -  int scheme         = s->orig_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]));
    --- End diff --
    
    I'm fine with use of StringView, but I think we should use it both request side and response side. Why don't we  do the change separately from this FIX? Ideally, the logic should be unified.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver issue #1520: Report protocol in request via header

Posted by atsci <gi...@git.apache.org>.
Github user atsci commented on the issue:

    https://github.com/apache/trafficserver/pull/1520
  
    FreeBSD build *successful*! See https://ci.trafficserver.apache.org/job/freebsd-github/1656/ for details.
     



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver pull request #1520: Report protocol in request via header

Posted by shukitchan <gi...@git.apache.org>.
Github user shukitchan closed the pull request at:

    https://github.com/apache/trafficserver/pull/1520


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver issue #1520: Report protocol in request via header

Posted by atsci <gi...@git.apache.org>.
Github user atsci commented on the issue:

    https://github.com/apache/trafficserver/pull/1520
  
    Linux build *failed*! See https://ci.trafficserver.apache.org/job/RAT-github/4/ for details.
     



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver pull request #1520: Report protocol in request via header

Posted by shukitchan <gi...@git.apache.org>.
Github user shukitchan commented on a diff in the pull request:

    https://github.com/apache/trafficserver/pull/1520#discussion_r104076857
  
    --- Diff: proxy/http/HttpTransactHeaders.cc ---
    @@ -741,26 +741,14 @@ HttpTransactHeaders::insert_via_header_in_request(HttpTransact::State *s, HTTPHd
       }
     
       char *incoming_via = s->via_string;
    -  int scheme         = s->orig_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]));
    --- End diff --
    
    it is ok. I can make the change tonight for both request and response in this PR. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver issue #1520: Report protocol in request via header

Posted by atsci <gi...@git.apache.org>.
Github user atsci commented on the issue:

    https://github.com/apache/trafficserver/pull/1520
  
    Intel CC build *successful*! See https://ci.trafficserver.apache.org/job/icc-github/88/ for details.
     



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver pull request #1520: Report protocol in request via header

Posted by shukitchan <gi...@git.apache.org>.
Github user shukitchan commented on a diff in the pull request:

    https://github.com/apache/trafficserver/pull/1520#discussion_r104270172
  
    --- Diff: proxy/http/HttpTransactHeaders.cc ---
    @@ -741,26 +741,14 @@ HttpTransactHeaders::insert_via_header_in_request(HttpTransact::State *s, HTTPHd
       }
     
       char *incoming_via = s->via_string;
    -  int scheme         = s->orig_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]));
    --- End diff --
    
    Run into some trouble and Alan is helping me out now. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver issue #1520: Report protocol in request via header

Posted by atsci <gi...@git.apache.org>.
Github user atsci commented on the issue:

    https://github.com/apache/trafficserver/pull/1520
  
    Linux build *successful*! See https://ci.trafficserver.apache.org/job/linux-github/1552/ for details.
     



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver pull request #1520: Report protocol in request via header

Posted by zwoop <gi...@git.apache.org>.
Github user zwoop commented on a diff in the pull request:

    https://github.com/apache/trafficserver/pull/1520#discussion_r103943927
  
    --- Diff: proxy/http/HttpTransactHeaders.cc ---
    @@ -741,26 +741,14 @@ HttpTransactHeaders::insert_via_header_in_request(HttpTransact::State *s, HTTPHd
       }
     
       char *incoming_via = s->via_string;
    -  int scheme         = s->orig_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]));
    --- End diff --
    
    I mean exactly like that.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver issue #1520: Report protocol in request via header

Posted by atsci <gi...@git.apache.org>.
Github user atsci commented on the issue:

    https://github.com/apache/trafficserver/pull/1520
  
    clang-analyzer build *successful*! See https://ci.trafficserver.apache.org/job/clang-analyzer-github/220/ for details.
     



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver pull request #1520: Report protocol in request via header

Posted by zwoop <gi...@git.apache.org>.
Github user zwoop commented on a diff in the pull request:

    https://github.com/apache/trafficserver/pull/1520#discussion_r103819181
  
    --- Diff: proxy/http/HttpTransactHeaders.cc ---
    @@ -741,26 +741,14 @@ HttpTransactHeaders::insert_via_header_in_request(HttpTransact::State *s, HTTPHd
       }
     
       char *incoming_via = s->via_string;
    -  int scheme         = s->orig_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]));
    --- End diff --
    
    Aaah this is super unfortunate IMO, so now we have to do strlen() on all these strings, even though they are static? :-/. I remember having this conversation about the public APIs, but can we make something internal that doesn't have this shortcoming?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver issue #1520: Report protocol in request via header

Posted by shukitchan <gi...@git.apache.org>.
Github user shukitchan commented on the issue:

    https://github.com/apache/trafficserver/pull/1520
  
    #1534 is merged. So closing this one. Thanks @SolidWallOfCode 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] trafficserver pull request #1520: Report protocol in request via header

Posted by SolidWallOfCode <gi...@git.apache.org>.
Github user SolidWallOfCode commented on a diff in the pull request:

    https://github.com/apache/trafficserver/pull/1520#discussion_r103937152
  
    --- Diff: proxy/http/HttpTransactHeaders.cc ---
    @@ -741,26 +741,14 @@ HttpTransactHeaders::insert_via_header_in_request(HttpTransact::State *s, HTTPHd
       }
     
       char *incoming_via = s->via_string;
    -  int scheme         = s->orig_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]));
    --- End diff --
    
    You mean like `StringView`? E. g.
    ```
    std::array<StringView,10> proto_buf;
    int retval = s->state_machine->populate_client_protocol(proto_buf, proto_buf.size());
    for ( StringView const& s : proto_buf ) memcpy(via_string, s.ptr(), s.size());
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---