Browse Source

Merge pull request #9084 from afishbeck/expect100continue

HPCC-9440 Support HTTP Expect: 100-continue in Roxie and ESP

Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 8 years ago
parent
commit
1d6530e531
2 changed files with 14 additions and 1 deletions
  1. 6 0
      common/thorhelper/roxiehelper.cpp
  2. 8 1
      esp/bindings/http/platform/httptransport.cpp

+ 6 - 0
common/thorhelper/roxiehelper.cpp

@@ -1497,6 +1497,12 @@ bool CSafeSocket::readBlock(StringBuffer &ret, unsigned timeout, HttpHelper *pHt
                 if ((str = strstr(header, "Content-Type: ")) != NULL)
                     pHttpHelper->setContentType(str+14);
 
+                if (strstr(header, "Expect: 100-continue"))
+                {
+                    StringBuffer cont("HTTP/1.1 100 Continue\n\n"); //tell client to go ahead and send body
+                    sock->write(cont, cont.length());
+                }
+
                 // determine payload length
                 str = strstr(header, "Content-Length: ");
                 if (str)

+ 8 - 1
esp/bindings/http/platform/httptransport.cpp

@@ -604,7 +604,14 @@ int CHttpMessage::receive(bool alwaysReadContent, IMultiException *me)
 
     if (getEspLogLevel()>LogNormal)
         DBGLOG("Headers processed! content_length = %" I64F "d", m_content_length);
-    
+    StringBuffer expect;
+    getHeader("Expect", expect);
+    if (expect.length() && strieq(expect, "100-continue"))
+    {
+        StringBuffer cont("HTTP/1.1 100 Continue\n\n"); //tell client to send body
+        m_socket.write(cont, cont.length());
+    }
+
     if (isUpload())
         return 0;