]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix reason-phrase mangling
authorAmos Jeffries <squid3@treenet.co.nz>
Sat, 15 Nov 2014 17:57:14 +0000 (09:57 -0800)
committerAmos Jeffries <squid3@treenet.co.nz>
Sat, 15 Nov 2014 17:57:14 +0000 (09:57 -0800)
The legacy code reason-phrase requires const char*, which we no longer
have. We get an SBUf from the parser instead.
To avoid c_str() performance regressions or bloating the code with
StatusLine alterations we must take advantage of the default reason
phrases on output and RFC permission to ignore phrases delivered by the
server.

src/http.cc

index 81bc2bba480163a3fe661715d2c57b8902e167b7..17a849df1e1ff159414cdeaf2df0ef0e84423c8a 100644 (file)
@@ -753,8 +753,10 @@ HttpStateData::processReplyHeader()
     payloadSeen = inBuf.length();
 
     HttpReply *newrep = new HttpReply;
-    // XXX: performance regression, c_str() reallocates.
-    newrep->sline.set(Http::ProtocolVersion(1,1), hp->messageStatus(), hp->reasonPhrase().c_str());
+    // XXX: RFC 7230 indicates we MAY ignore the reason phrase,
+    //      and use an empty string on unknown status.
+    //      We do that now to avoid performance regression from using SBuf::c_str()
+    newrep->sline.set(Http::ProtocolVersion(1,1), hp->messageStatus() /* , hp->reasonPhrase() */);
     newrep->sline.protocol = newrep->sline.version.protocol = hp->messageProtocol().protocol;
     newrep->sline.version.major = hp->messageProtocol().major;
     newrep->sline.version.minor = hp->messageProtocol().minor;