You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2017/11/07 17:44:56 UTC

[trafficserver] branch master updated: TS-5057: Add 103 Early Hints support

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

zwoop pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 1a9944c  TS-5057: Add 103 Early Hints support
1a9944c is described below

commit 1a9944ce2ffd1c54ef0fb3e30ecd539a28b8b028
Author: Masaori Koshiba <ma...@apache.org>
AuthorDate: Mon Nov 6 10:30:47 2017 +0900

    TS-5057: Add 103 Early Hints support
---
 doc/developer-guide/api/types/TSHttpStatus.en.rst |  2 ++
 lib/cppapi/include/atscppapi/HttpStatus.h         |  1 +
 lib/ts/apidefs.h.in                               |  1 +
 lib/ts/mkdfa.c                                    |  1 +
 proxy/InkAPITest.cc                               | 14 +++++++++++++-
 proxy/hdrs/HTTP.cc                                |  1 +
 proxy/hdrs/HTTP.h                                 |  1 +
 proxy/http/HttpTransact.cc                        |  3 ++-
 8 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/doc/developer-guide/api/types/TSHttpStatus.en.rst b/doc/developer-guide/api/types/TSHttpStatus.en.rst
index 13b2ae6..f689049 100644
--- a/doc/developer-guide/api/types/TSHttpStatus.en.rst
+++ b/doc/developer-guide/api/types/TSHttpStatus.en.rst
@@ -47,6 +47,8 @@ Enumeration Members
 
 .. c:member:: TSHttpStatus TS_HTTP_STATUS_SWITCHING_PROTOCOL
 
+.. c:member:: TSHttpStatus TS_HTTP_STATUS_EARLY_HINTS
+
 .. c:member:: TSHttpStatus TS_HTTP_STATUS_OK
 
 .. c:member:: TSHttpStatus TS_HTTP_STATUS_CREATED
diff --git a/lib/cppapi/include/atscppapi/HttpStatus.h b/lib/cppapi/include/atscppapi/HttpStatus.h
index 5c2e373..071aef1 100644
--- a/lib/cppapi/include/atscppapi/HttpStatus.h
+++ b/lib/cppapi/include/atscppapi/HttpStatus.h
@@ -37,6 +37,7 @@ enum HttpStatus {
 
   HTTP_STATUS_CONTINUE           = 100,
   HTTP_STATUS_SWITCHING_PROTOCOL = 101,
+  HTTP_STATUS_EARLY_HINTS        = 103,
 
   HTTP_STATUS_OK                            = 200,
   HTTP_STATUS_CREATED                       = 201,
diff --git a/lib/ts/apidefs.h.in b/lib/ts/apidefs.h.in
index bc57553..5442299 100644
--- a/lib/ts/apidefs.h.in
+++ b/lib/ts/apidefs.h.in
@@ -155,6 +155,7 @@ typedef enum {
   TS_HTTP_STATUS_NONE                            = 0,
   TS_HTTP_STATUS_CONTINUE                        = 100,
   TS_HTTP_STATUS_SWITCHING_PROTOCOL              = 101,
+  TS_HTTP_STATUS_EARLY_HINTS                     = 103,
   TS_HTTP_STATUS_OK                              = 200,
   TS_HTTP_STATUS_CREATED                         = 201,
   TS_HTTP_STATUS_ACCEPTED                        = 202,
diff --git a/lib/ts/mkdfa.c b/lib/ts/mkdfa.c
index 3767b0c..9dcc890 100644
--- a/lib/ts/mkdfa.c
+++ b/lib/ts/mkdfa.c
@@ -138,6 +138,7 @@ info_t methods[] = {
 info_t statuses[] = {
   {"100", "HTTP_STATUS_CONTINUE", -1},
   {"101", "HTTP_STATUS_SWITCHING_PROTOCOL", -1},
+  {"103", "HTTP_STATUS_EARLY_HINTS", -1},
   {"200", "HTTP_STATUS_OK", -1},
   {"201", "HTTP_STATUS_CREATED", -1},
   {"202", "HTTP_STATUS_ACCEPTED", -1},
diff --git a/proxy/InkAPITest.cc b/proxy/InkAPITest.cc
index bf5435f..84d6f55 100644
--- a/proxy/InkAPITest.cc
+++ b/proxy/InkAPITest.cc
@@ -3278,7 +3278,7 @@ REGRESSION_TEST(SDK_API_TSHttpHdr)(RegressionTest *test, int /* atype ATS_UNUSED
   }
 
   if (strcmp("Not Modified", TSHttpHdrReasonLookup(TS_HTTP_STATUS_NOT_MODIFIED)) != 0) {
-    SDK_RPRINT(test, "TSHttpHdrReasonLookup", "TestCase2", TC_FAIL, "TSHttpHdrReasonLookup returns Value's mismatch");
+    SDK_RPRINT(test, "TSHttpHdrReasonLookup", "TestCase4", TC_FAIL, "TSHttpHdrReasonLookup returns Value's mismatch");
     if (test_passed_Http_Hdr_Reason_Lookup == true) {
       test_passed_Http_Hdr_Reason_Lookup = false;
     }
@@ -3286,6 +3286,15 @@ REGRESSION_TEST(SDK_API_TSHttpHdr)(RegressionTest *test, int /* atype ATS_UNUSED
     SDK_RPRINT(test, "TSHttpHdrReasonLookup", "TestCase4", TC_PASS, "ok");
   }
 
+  if (strcmp("Early Hints", TSHttpHdrReasonLookup(TS_HTTP_STATUS_EARLY_HINTS)) != 0) {
+    SDK_RPRINT(test, "TSHttpHdrReasonLookup", "TestCase5", TC_FAIL, "TSHttpHdrReasonLookup returns Value's mismatch");
+    if (test_passed_Http_Hdr_Reason_Lookup == true) {
+      test_passed_Http_Hdr_Reason_Lookup = false;
+    }
+  } else {
+    SDK_RPRINT(test, "TSHttpHdrReasonLookup", "TestCase5", TC_PASS, "ok");
+  }
+
   // Copy
   if (test_passed_Http_Hdr_Create == true) {
     if (TSHttpHdrCopy(bufp3, hdr_loc3, bufp1, hdr_loc1) == TS_ERROR) {
@@ -5470,6 +5479,7 @@ typedef enum {
 
   ORIG_TS_HTTP_STATUS_CONTINUE           = 100,
   ORIG_TS_HTTP_STATUS_SWITCHING_PROTOCOL = 101,
+  ORIG_TS_HTTP_STATUS_EARLY_HINTS        = 103,
 
   ORIG_TS_HTTP_STATUS_OK                            = 200,
   ORIG_TS_HTTP_STATUS_CREATED                       = 201,
@@ -5640,6 +5650,8 @@ REGRESSION_TEST(SDK_API_TSConstant)(RegressionTest *test, int /* atype ATS_UNUSE
   PRINT_DIFF(TS_HTTP_STATUS_NONE);
   PRINT_DIFF(TS_HTTP_STATUS_CONTINUE);
   PRINT_DIFF(TS_HTTP_STATUS_SWITCHING_PROTOCOL);
+  PRINT_DIFF(TS_HTTP_STATUS_EARLY_HINTS);
+
   PRINT_DIFF(TS_HTTP_STATUS_OK);
   PRINT_DIFF(TS_HTTP_STATUS_CREATED);
 
diff --git a/proxy/hdrs/HTTP.cc b/proxy/hdrs/HTTP.cc
index 69335e0..f0eac84 100644
--- a/proxy/hdrs/HTTP.cc
+++ b/proxy/hdrs/HTTP.cc
@@ -749,6 +749,7 @@ http_hdr_reason_lookup(unsigned status)
     HTTP_STATUS_ENTRY(100, Continue);            // [RFC2616]
     HTTP_STATUS_ENTRY(101, Switching Protocols); // [RFC2616]
     HTTP_STATUS_ENTRY(102, Processing);          // [RFC2518]
+    HTTP_STATUS_ENTRY(103, Early Hints);         // TODO: add RFC number
     // 103-199 Unassigned
     HTTP_STATUS_ENTRY(200, OK);                              // [RFC2616]
     HTTP_STATUS_ENTRY(201, Created);                         // [RFC2616]
diff --git a/proxy/hdrs/HTTP.h b/proxy/hdrs/HTTP.h
index 4c599fd..62f01b3 100644
--- a/proxy/hdrs/HTTP.h
+++ b/proxy/hdrs/HTTP.h
@@ -43,6 +43,7 @@ enum HTTPStatus {
 
   HTTP_STATUS_CONTINUE           = 100,
   HTTP_STATUS_SWITCHING_PROTOCOL = 101,
+  HTTP_STATUS_EARLY_HINTS        = 103,
 
   HTTP_STATUS_OK                            = 200,
   HTTP_STATUS_CREATED                       = 201,
diff --git a/proxy/http/HttpTransact.cc b/proxy/http/HttpTransact.cc
index 2d8cdf2..1053bec 100644
--- a/proxy/http/HttpTransact.cc
+++ b/proxy/http/HttpTransact.cc
@@ -3798,7 +3798,8 @@ HttpTransact::handle_forward_server_connection_open(State *s)
     // dont update the hostdb. let us try again with what we currently think.
   }
 
-  if (s->hdr_info.server_response.status_get() == HTTP_STATUS_CONTINUE) {
+  if (s->hdr_info.server_response.status_get() == HTTP_STATUS_CONTINUE ||
+      s->hdr_info.server_response.status_get() == HTTP_STATUS_EARLY_HINTS) {
     handle_100_continue_response(s);
     return;
   }

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