]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Merge from trunk rev.13687
authorAmos Jeffries <squid3@treenet.co.nz>
Wed, 5 Nov 2014 10:18:15 +0000 (02:18 -0800)
committerAmos Jeffries <squid3@treenet.co.nz>
Wed, 5 Nov 2014 10:18:15 +0000 (02:18 -0800)
16 files changed:
1  2 
configure.ac
src/HttpHeader.h
src/HttpRequest.cc
src/HttpRequest.h
src/Makefile.am
src/MemObject.h
src/acl/MethodData.h
src/client_side.cc
src/client_side.h
src/htcp.cc
src/mgr/ActionWriter.h
src/mgr/Filler.h
src/mime.cc
src/servers/FtpServer.cc
src/servers/FtpServer.h
src/servers/HttpServer.cc

diff --cc configure.ac
Simple merge
Simple merge
Simple merge
Simple merge
diff --cc src/Makefile.am
Simple merge
diff --cc src/MemObject.h
Simple merge
index 5c6aff2eeff9c080214658761f00a6128773a01a,5bba166cf240122bffc666e88efc0112dabb037b..a3c02dcafb6fe53884e017106a1a2fc9e62503b6
  
  #include "acl/Acl.h"
  #include "acl/Data.h"
- #include "CbDataList.h"
+ #include "base/CbDataList.h"
 -#include "HttpRequestMethod.h"
 +#include "http/RequestMethod.h"
  
- /// \ingroup ACLAPI
  class ACLMethodData : public ACLData<HttpRequestMethod>
  {
- public:
      MEMPROXY_CLASS(ACLMethodData);
  
+ public:
      ACLMethodData();
      ACLMethodData(ACLMethodData const &);
      ACLMethodData &operator= (ACLMethodData const &);
index 82b17ea58fdecedb64653984ac61e7dd394a3311,22a08b5fdcb5a825b21065854c2464123a6b6b11..34a77c01ec9348f2b8f0473f90cf0d0ffe0c25ca
@@@ -2075,15 -2052,14 +2075,13 @@@ prepareAcceleratedURL(ConnStateData * c
                  host = thost;
              }
          } // else nothing to alter port-wise.
 -        int url_sz = strlen(url) + 32 + Config.appendDomainLen +
 -                     strlen(host);
 +        const int url_sz = hp->requestUri().length() + 32 + Config.appendDomainLen + strlen(host);
          http->uri = (char *)xcalloc(url_sz, 1);
-         const char *protocol = switchedToHttps ?
-                                "https" : AnyP::UriScheme(conn->port->transport.protocol).c_str();
-         snprintf(http->uri, url_sz, "%s://%s" SQUIDSBUFPH, protocol, host, SQUIDSBUFPRINT(url));
 -        snprintf(http->uri, url_sz, "%s://%s%s", AnyP::UriScheme(conn->transferProtocol.protocol).c_str(), host, url);
 -        debugs(33, 5, "ACCEL VHOST REWRITE: '" << http->uri << "'");
++        snprintf(http->uri, url_sz, "%s://%s" SQUIDSBUFPH, AnyP::UriScheme(conn->transferProtocol.protocol).c_str(), host, SQUIDSBUFPRINT(url));
 +        debugs(33, 5, "ACCEL VHOST REWRITE: " << http->uri);
      } else if (conn->port->defaultsite /* && !vhost */) {
          debugs(33, 5, "ACCEL DEFAULTSITE REWRITE: defaultsite=" << conn->port->defaultsite << " + vport=" << vport);
 -        int url_sz = strlen(url) + 32 + Config.appendDomainLen +
 +        const int url_sz = hp->requestUri().length() + 32 + Config.appendDomainLen +
                       strlen(conn->port->defaultsite);
          http->uri = (char *)xcalloc(url_sz, 1);
          char vportStr[32];
          if (vport > 0) {
              snprintf(vportStr, sizeof(vportStr),":%d",vport);
          }
 -        snprintf(http->uri, url_sz, "%s://%s%s%s",
 -                 AnyP::UriScheme(conn->transferProtocol.protocol).c_str(), conn->port->defaultsite, vportStr, url);
 -        debugs(33, 5, "ACCEL DEFAULTSITE REWRITE: '" << http->uri <<"'");
 +        snprintf(http->uri, url_sz, "%s://%s%s" SQUIDSBUFPH,
-                  AnyP::UriScheme(conn->port->transport.protocol).c_str(), conn->port->defaultsite, vportStr, SQUIDSBUFPRINT(url));
++                 AnyP::UriScheme(conn->transferProtocol.protocol).c_str(), conn->port->defaultsite, vportStr, SQUIDSBUFPRINT(url));
 +        debugs(33, 5, "ACCEL DEFAULTSITE REWRITE: " << http->uri);
      } else if (vport > 0 /* && (!vhost || no Host:) */) {
          debugs(33, 5, "ACCEL VPORT REWRITE: *_port IP + vport=" << vport);
          /* Put the local socket IP address as the hostname, with whatever vport we found  */
 -        int url_sz = strlen(url) + 32 + Config.appendDomainLen;
 +        const int url_sz = hp->requestUri().length() + 32 + Config.appendDomainLen;
          http->uri = (char *)xcalloc(url_sz, 1);
          http->getConn()->clientConnection->local.toHostStr(ipbuf,MAX_IPSTRLEN);
 -        snprintf(http->uri, url_sz, "%s://%s:%d%s",
 +        snprintf(http->uri, url_sz, "%s://%s:%d" SQUIDSBUFPH,
-                  AnyP::UriScheme(conn->port->transport.protocol).c_str(),
+                  AnyP::UriScheme(conn->transferProtocol.protocol).c_str(),
 -                 ipbuf, vport, url);
 -        debugs(33, 5, "ACCEL VPORT REWRITE: '" << http->uri << "'");
 +                 ipbuf, vport, SQUIDSBUFPRINT(url));
 +        debugs(33, 5, "ACCEL VPORT REWRITE: " << http->uri);
      }
  }
  
@@@ -2116,23 -2094,21 +2114,23 @@@ prepareTransparentURL(ConnStateData * c
  
      /* BUG: Squid cannot deal with '*' URLs (RFC2616 5.1.2) */
  
 -    if ((host = mime_get_header(req_hdr, "Host")) != NULL) {
 -        int url_sz = strlen(url) + 32 + Config.appendDomainLen +
 +    if (const char *host = hp->getHeaderField("Host")) {
 +        const int url_sz = hp->requestUri().length() + 32 + Config.appendDomainLen +
                       strlen(host);
          http->uri = (char *)xcalloc(url_sz, 1);
 -        snprintf(http->uri, url_sz, "%s://%s%s", AnyP::UriScheme(conn->transferProtocol.protocol).c_str(), host, url);
 -        debugs(33, 5, "TRANSPARENT HOST REWRITE: '" << http->uri <<"'");
 +        snprintf(http->uri, url_sz, "%s://%s" SQUIDSBUFPH,
-              AnyP::UriScheme(conn->port->transport.protocol).c_str(), host, SQUIDSBUFPRINT(hp->requestUri()));
++             AnyP::UriScheme(conn->transferProtocol.protocol).c_str(), host, SQUIDSBUFPRINT(hp->requestUri()));
 +        debugs(33, 5, "TRANSPARENT HOST REWRITE: " << http->uri);
      } else {
          /* Put the local socket IP address as the hostname.  */
 -        int url_sz = strlen(url) + 32 + Config.appendDomainLen;
 +        const int url_sz = hp->requestUri().length() + 32 + Config.appendDomainLen;
          http->uri = (char *)xcalloc(url_sz, 1);
 +        static char ipbuf[MAX_IPSTRLEN];
          http->getConn()->clientConnection->local.toHostStr(ipbuf,MAX_IPSTRLEN);
 -        snprintf(http->uri, url_sz, "%s://%s:%d%s",
 +        snprintf(http->uri, url_sz, "%s://%s:%d" SQUIDSBUFPH,
-                  AnyP::UriScheme(http->getConn()->port->transport.protocol).c_str(),
+                  AnyP::UriScheme(http->getConn()->transferProtocol.protocol).c_str(),
 -                 ipbuf, http->getConn()->clientConnection->local.port(), url);
 -        debugs(33, 5, "TRANSPARENT REWRITE: '" << http->uri << "'");
 +                 ipbuf, http->getConn()->clientConnection->local.port(), SQUIDSBUFPRINT(hp->requestUri()));
 +        debugs(33, 5, "TRANSPARENT REWRITE: " << http->uri);
      }
  }
  
   *          a ClientSocketContext structure on success or failure.
   */
  ClientSocketContext *
 -parseHttpRequest(ConnStateData *csd, HttpParser *hp, HttpRequestMethod * method_p, Http::ProtocolVersion *http_ver)
 +parseHttpRequest(ConnStateData *csd, const Http1::RequestParserPointer &hp)
  {
 -    char *req_hdr = NULL;
 -    char *end;
 -    size_t req_sz;
 -    ClientHttpRequest *http;
 -    ClientSocketContext *result;
 -    StoreIOBuffer tempBuffer;
 -    int r;
 -
 -    /* pre-set these values to make aborting simpler */
 -    *method_p = Http::METHOD_NONE;
 -
 -    /* NP: don't be tempted to move this down or remove again.
 -     * It's the only DDoS protection old-String has against long URL */
 -    if ( hp->bufsiz <= 0) {
 -        debugs(33, 5, "Incomplete request, waiting for end of request line");
 -        return NULL;
 -    } else if ( (size_t)hp->bufsiz >= Config.maxRequestHeaderSize && headersEnd(hp->buf, Config.maxRequestHeaderSize) == 0) {
 -        debugs(33, 5, "parseHttpRequest: Too large request");
 -        hp->request_parse_status = Http::scHeaderTooLarge;
 -        return csd->abortRequestParsing("error:request-too-large");
 -    }
 -
 -    /* Attempt to parse the first line; this'll define the method, url, version and header begin */
 -    r = HttpParserParseReqLine(hp);
 -
 -    if (r == 0) {
 -        debugs(33, 5, "Incomplete request, waiting for end of request line");
 -        return NULL;
 -    }
 -
 -    if (r == -1) {
 -        return csd->abortRequestParsing("error:invalid-request");
 -    }
 +    /* Attempt to parse the first line; this will define where the method, url, version and header begin */
 +    {
 +        const bool parsedOk = hp->parse(csd->in.buf);
  
 -    /* Request line is valid here .. */
 -    *http_ver = Http::ProtocolVersion(hp->req.v_maj, hp->req.v_min);
 +        // sync the buffers after parsing.
 +        csd->in.buf = hp->remaining();
  
 -    /* This call scans the entire request, not just the headers */
 -    if (hp->req.v_maj > 0) {
 -        if ((req_sz = headersEnd(hp->buf, hp->bufsiz)) == 0) {
 -            debugs(33, 5, "Incomplete request, waiting for end of headers");
 +        if (hp->needsMoreData()) {
 +            debugs(33, 5, "Incomplete request, waiting for end of request line");
              return NULL;
          }
 -    } else {
 -        debugs(33, 3, "parseHttpRequest: Missing HTTP identifier");
 -        req_sz = HttpParserReqSz(hp);
 -    }
 -
 -    /* We know the whole request is in hp->buf now */
 -
 -    assert(req_sz <= (size_t) hp->bufsiz);
  
 -    /* Will the following be true with HTTP/0.9 requests? probably not .. */
 -    /* So the rest of the code will need to deal with '0'-byte headers (ie, none, so don't try parsing em) */
 -    assert(req_sz > 0);
 +        if (!parsedOk) {
 +            if (hp->request_parse_status == Http::scRequestHeaderFieldsTooLarge || hp->request_parse_status == Http::scUriTooLong)
 +                return csd->abortRequestParsing("error:request-too-large");
  
 -    hp->hdr_end = req_sz - 1;
 -
 -    hp->hdr_start = hp->req.end + 1;
 -
 -    /* Enforce max_request_size */
 -    if (req_sz >= Config.maxRequestHeaderSize) {
 -        debugs(33, 5, "parseHttpRequest: Too large request");
 -        hp->request_parse_status = Http::scHeaderTooLarge;
 -        return csd->abortRequestParsing("error:request-too-large");
 +            return csd->abortRequestParsing("error:invalid-request");
 +        }
      }
  
 -    /* Set method_p */
 -    *method_p = HttpRequestMethod(&hp->buf[hp->req.m_start], &hp->buf[hp->req.m_end]+1);
 +    /* We know the whole request is in parser now */
 +    debugs(11, 2, "HTTP Client " << csd->clientConnection);
 +    debugs(11, 2, "HTTP Client REQUEST:\n---------\n" <<
 +           hp->method() << " " << hp->requestUri() << " " << hp->messageProtocol() << "\n" <<
 +           hp->mimeHeader() <<
 +           "\n----------");
  
      /* deny CONNECT via accelerated ports */
 -    if (*method_p == Http::METHOD_CONNECT && csd->port != NULL && csd->port->flags.accelSurrogate) {
 +    if (hp->method() == Http::METHOD_CONNECT && csd->port != NULL && csd->port->flags.accelSurrogate) {
-         debugs(33, DBG_IMPORTANT, "WARNING: CONNECT method received on " << csd->port->transport.protocol << " Accelerator port " << csd->port->s.port());
+         debugs(33, DBG_IMPORTANT, "WARNING: CONNECT method received on " << csd->transferProtocol << " Accelerator port " << csd->port->s.port());
 -        /* XXX need a way to say "this many character length string" */
 -        debugs(33, DBG_IMPORTANT, "WARNING: for request: " << hp->buf);
 +        debugs(33, DBG_IMPORTANT, "WARNING: for request: " << hp->method() << " " << hp->requestUri() << " " << hp->messageProtocol());
          hp->request_parse_status = Http::scMethodNotAllowed;
          return csd->abortRequestParsing("error:method-not-allowed");
      }
Simple merge
diff --cc src/htcp.cc
index 3e356eee2a02dbb2bc8cfcac06d0c7f212ae3418,129a3aaa453325e03b78d77d4df2bd930e24c962..faa2f6cc29ca7d68ae7877e5eebe11ca84d23a59
@@@ -159,17 -157,10 +158,15 @@@ private
      htcpDataHeader *dhdr;
  };
  
- MEMPROXY_CLASS_INLINE(htcpSpecifier);
  struct _htcpDetail {
      char *resp_hdrs;
 +    size_t respHdrsSz;
 +
      char *entity_hdrs;
 +    size_t entityHdrsSz;
 +
      char *cache_hdrs;
 +    size_t cacheHdrsSz;
  };
  
  struct _htcpStuff {
Simple merge
Simple merge
diff --cc src/mime.cc
Simple merge
Simple merge
Simple merge
Simple merge