Skip to content

Commit

Permalink
Format code
Browse files Browse the repository at this point in the history
Signed-off-by: Erica Manno <[email protected]>
  • Loading branch information
rulex123 committed Jul 13, 2020
1 parent 397e369 commit c139ff1
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
3 changes: 2 additions & 1 deletion include/envoy/http/codec.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ class ResponseEncoder : public virtual StreamEncoder {
virtual void encodeTrailers(const ResponseTrailerMap& trailers) PURE;

/**
* Indicates whether invalid HTTP messaging should be handled with a stream error or a connection error.
* Indicates whether invalid HTTP messaging should be handled with a stream error or a connection
* error.
*/
virtual absl::optional<bool> streamErrorOnInvalidHttpMessage() PURE;
};
Expand Down
6 changes: 4 additions & 2 deletions source/common/http/utility.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "common/http/header_map_impl.h"
#include "common/http/headers.h"
#include "common/http/message_impl.h"
#include "common/http/utility.h"
#include "common/network/utility.h"
#include "common/protobuf/utility.h"

Expand Down Expand Up @@ -407,8 +408,9 @@ Utility::parseHttp1Settings(const envoy::config::core::v3::Http1ProtocolOptions&
return ret;
}

bool Utility::streamErrorOnInvalidHttpMessageForHttp1(bool hcm_stream_error_on_invalid_http_message,
const absl::optional<bool>& override_stream_error_on_invalid_http_message) {
bool Utility::streamErrorOnInvalidHttpMessageForHttp1(
bool hcm_stream_error_on_invalid_http_message,
const absl::optional<bool>& override_stream_error_on_invalid_http_message) {
if (override_stream_error_on_invalid_http_message.has_value()) {
return override_stream_error_on_invalid_http_message.value();
} else {
Expand Down
6 changes: 3 additions & 3 deletions source/common/http/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,9 @@ bool isWebSocketUpgradeRequest(const RequestHeaderMap& headers);
*/
Http1Settings parseHttp1Settings(const envoy::config::core::v3::Http1ProtocolOptions& config);

bool streamErrorOnInvalidHttpMessageForHttp1(
const bool hcm_stream_error_on_invalid_http_message,
const absl::optional<bool>& override_stream_error_on_invalid_http_message);
bool streamErrorOnInvalidHttpMessageForHttp1(
const bool hcm_stream_error_on_invalid_http_message,
const absl::optional<bool>& override_stream_error_on_invalid_http_message);

struct EncodeFunctions {
// Function to rewrite locally generated response.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include "extensions/filters/network/http_connection_manager/config.h"

#include <chrono>
#include <memory>
#include <string>
Expand Down Expand Up @@ -33,6 +31,8 @@
#include "common/tracing/http_tracer_config_impl.h"
#include "common/tracing/http_tracer_manager_impl.h"

#include "extensions/filters/network/http_connection_manager/config.h"

namespace Envoy {
namespace Extensions {
namespace NetworkFilters {
Expand Down
12 changes: 8 additions & 4 deletions test/common/http/utility_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -359,20 +359,24 @@ TEST(HttpUtility, ValidateStreamErrorsWithHcmForHttp1) {
// If the override value is present, it will take precedence over the HCM value.
bool hcm_stream_error = false;
absl::optional<bool> override_stream_error = true;
EXPECT_TRUE(Http::Utility::streamErrorOnInvalidHttpMessageForHttp1(hcm_stream_error, override_stream_error));
EXPECT_TRUE(Http::Utility::streamErrorOnInvalidHttpMessageForHttp1(hcm_stream_error,
override_stream_error));

hcm_stream_error = true;
override_stream_error = false;
EXPECT_FALSE(Http::Utility::streamErrorOnInvalidHttpMessageForHttp1(hcm_stream_error, override_stream_error));
EXPECT_FALSE(Http::Utility::streamErrorOnInvalidHttpMessageForHttp1(hcm_stream_error,
override_stream_error));

// If the override value is not set, the HCM value will be used.
hcm_stream_error = false;
override_stream_error.reset();
EXPECT_FALSE(Http::Utility::streamErrorOnInvalidHttpMessageForHttp1(hcm_stream_error, override_stream_error));
EXPECT_FALSE(Http::Utility::streamErrorOnInvalidHttpMessageForHttp1(hcm_stream_error,
override_stream_error));

hcm_stream_error = true;
override_stream_error.reset();
EXPECT_TRUE(Http::Utility::streamErrorOnInvalidHttpMessageForHttp1(hcm_stream_error, override_stream_error));
EXPECT_TRUE(Http::Utility::streamErrorOnInvalidHttpMessageForHttp1(hcm_stream_error,
override_stream_error));
}

TEST(HttpUtility, getLastAddressFromXFF) {
Expand Down

0 comments on commit c139ff1

Please sign in to comment.