From: Amos Jeffries Date: Sat, 15 Nov 2014 17:57:14 +0000 (-0800) Subject: Fix reason-phrase mangling X-Git-Tag: merge-candidate-3-v1~240^2~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=62f9b110b503adebe76d552878e610d011f38c2d;p=thirdparty%2Fsquid.git Fix reason-phrase mangling 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. --- diff --git a/src/http.cc b/src/http.cc index 81bc2bba48..17a849df1e 100644 --- a/src/http.cc +++ b/src/http.cc @@ -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;