Skip to content

Commit

Permalink
reviewer comments
Browse files Browse the repository at this point in the history
Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
  • Loading branch information
alyssawilk committed May 19, 2020
1 parent 51ea977 commit fd0853f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion source/common/http/conn_manager_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1716,7 +1716,8 @@ void ConnectionManagerImpl::ActiveStream::encodeHeadersInternal(ResponseHeaderMa
// If the connection manager is draining send "Connection: Close" on HTTP/1.1 connections.
// Do not do this for H2 (which drains via GOAWAY) or Upgrade or CONNECT (as the
// payload is no longer HTTP/1.1)
if (!Utility::isUpgrade(headers) && !HeaderUtility::isConnectResponse(request_headers_, *response_headers_)) {
if (!Utility::isUpgrade(headers) &&
!HeaderUtility::isConnectResponse(request_headers_, *response_headers_)) {
headers.setReferenceConnection(Headers::get().ConnectionValues.Close);
}
}
Expand Down
3 changes: 2 additions & 1 deletion source/common/http/header_utility.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ bool HeaderUtility::isConnect(const RequestHeaderMap& headers) {
bool HeaderUtility::isConnectResponse(const RequestHeaderMapPtr& request_headers,
const ResponseHeaderMap& response_headers) {
return request_headers.get() && isConnect(*request_headers) &&
Http::Utility::getResponseStatus(response_headers) == 200;
static_cast<Http::Code>(Http::Utility::getResponseStatus(response_headers)) ==
Http::Code::OK;
}

void HeaderUtility::addHeaders(HeaderMap& headers, const HeaderMap& headers_to_add) {
Expand Down
7 changes: 4 additions & 3 deletions source/common/http/http1/codec_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ void StreamEncoderImpl::encodeHeadersBase(const RequestOrResponseHeaderMap& head
} else if (connection_.protocol() == Protocol::Http10) {
chunk_encoding_ = false;
} else {
// For responses to connct requests, do not send the chunked encoding header:
// For responses to connect requests, do not send the chunked encoding header:
// https://tools.ietf.org/html/rfc7231#section-4.3.6
if (!is_response_to_connect_request_) {
encodeFormattedHeader(Headers::get().TransferEncoding.get(),
Expand Down Expand Up @@ -1055,10 +1055,11 @@ int ClientConnectionImpl::onHeadersComplete() {
ENVOY_CONN_LOG(trace, "codec entering upgrade mode for CONNECT response.", connection_);
handling_upgrade_ = true;

// For responses to connct requests, do not accept the chunked
// For responses to connect requests, do not accept the chunked
// encoding header: https://tools.ietf.org/html/rfc7231#section-4.3.6
if (headers->TransferEncoding() &&
absl::EqualsIgnoreCase(headers->TransferEncoding()->value().getStringView(), Headers::get().TransferEncodingValues.Chunked)) {
absl::EqualsIgnoreCase(headers->TransferEncoding()->value().getStringView(),
Headers::get().TransferEncodingValues.Chunked)) {
sendProtocolError(Http1ResponseCodeDetails::get().InvalidTransferEncoding);
throw CodecProtocolException("http/1.1 protocol error: unsupported transfer encoding");
}
Expand Down

0 comments on commit fd0853f

Please sign in to comment.