Give full Request-URI to eCAP adapters.

Implement libecap::RequestLine::uri() to return full Request-URI instead
of URL path.

Niether full URL nor URL path is perfect because the actual request may
have full URI or a path, but Squid does not really keep that
information. This change makes our eCAP implementation consistent with
our ICAP implementation.


Eventually, eCAP may have an API that is guaranteed to return full
Request-URI and Squid may remember what kind of URI it got in the virgin
request, allowing for a more truthful implementation.


Thank you,

Alex.

Implement libecap::RequestLine::uri() to return full Request-URI
instead of URL path.

Niether is perfect because the actual request may have full URI or a path, but
Squid does not really keep that information. This change makes our eCAP
implementation consistent with our ICAP implementation. Note that ICAP (RFC
3507) examples show URL paths rather than full URIs being sent to ICAP
servers.


=== modified file 'src/adaptation/ecap/MessageRep.cc'
--- src/adaptation/ecap/MessageRep.cc	2011-02-18 23:58:13 +0000
+++ src/adaptation/ecap/MessageRep.cc	2011-02-23 15:20:18 +0000
@@ -194,42 +194,44 @@
 Adaptation::Ecap::RequestLineRep::RequestLineRep(HttpRequest &aMessage):
         FirstLineRep(aMessage), theMessage(aMessage)
 {
 }
 
 void
 Adaptation::Ecap::RequestLineRep::uri(const Area &aUri)
 {
     // TODO: if method is not set, urlPath will assume it is not connect;
     // Can we change urlParse API to remove the method parameter?
     // TODO: optimize: urlPath should take constant URL buffer
     char *buf = xstrdup(aUri.toString().c_str());
     const bool ok = urlParse(theMessage.method, buf, &theMessage);
     xfree(buf);
     Must(ok);
 }
 
 Adaptation::Ecap::RequestLineRep::Area
 Adaptation::Ecap::RequestLineRep::uri() const
 {
-    return Area::FromTempBuffer(theMessage.urlpath.rawBuf(),
-                                theMessage.urlpath.size());
+    const char *fullUrl = urlCanonical(&theMessage);
+    Must(fullUrl);
+    // optimize: avoid copying by having an Area::Detail that locks theMessage
+    return Area::FromTempBuffer(fullUrl, strlen(fullUrl));
 }
 
 void
 Adaptation::Ecap::RequestLineRep::method(const Name &aMethod)
 {
     if (aMethod.assignedHostId()) {
         const int id = aMethod.hostId();
         Must(METHOD_NONE < id && id < METHOD_ENUM_END);
         Must(id != METHOD_OTHER);
         theMessage.method = HttpRequestMethod(static_cast<_method_t>(id));
     } else {
         const std::string &image = aMethod.image();
         theMessage.method = HttpRequestMethod(image.data(),
                                               image.data() + image.size());
     }
 }
 
 Adaptation::Ecap::RequestLineRep::Name
 Adaptation::Ecap::RequestLineRep::method() const
 {

Reply via email to