| Index: net/http/http_network_transaction_unittest.cc
|
| diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc
|
| index 178ad60529e02259c68b37733fec80e05b252d82..841cd7a0563c4e0fc615306ab6b313802ab183e0 100644
|
| --- a/net/http/http_network_transaction_unittest.cc
|
| +++ b/net/http/http_network_transaction_unittest.cc
|
| @@ -16525,4 +16525,87 @@ TEST_F(HttpNetworkTransactionTest, TokenBindingSpdy) {
|
| }
|
| #endif // !defined(OS_IOS)
|
|
|
| +void CheckContentEncodingMatching(SpdySessionDependencies* session_deps,
|
| + const std::string& accept_encoding,
|
| + const std::string& content_encoding,
|
| + bool should_match) {
|
| + HttpRequestInfo request;
|
| + request.method = "GET";
|
| + request.url = GURL("http://www.foo.com/");
|
| + request.extra_headers.SetHeader(HttpRequestHeaders::kAcceptEncoding,
|
| + accept_encoding);
|
| +
|
| + std::unique_ptr<HttpNetworkSession> session(CreateSession(session_deps));
|
| + HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get());
|
| + // Send headers successfully, but get an error while sending the body.
|
| + MockWrite data_writes[] = {
|
| + MockWrite("GET / HTTP/1.1\r\n"
|
| + "Host: www.foo.com\r\n"
|
| + "Connection: keep-alive\r\n"
|
| + "Accept-Encoding: "),
|
| + MockWrite(accept_encoding.data()), MockWrite("\r\n\r\n"),
|
| + };
|
| +
|
| + MockRead data_reads[] = {
|
| + MockRead("HTTP/1.0 200 OK\r\n"), MockRead("Content-Encoding: "),
|
| + MockRead(content_encoding.data()), MockRead("\r\n\r\n"),
|
| + MockRead(SYNCHRONOUS, OK),
|
| + };
|
| + StaticSocketDataProvider data(data_reads, arraysize(data_reads), data_writes,
|
| + arraysize(data_writes));
|
| + session_deps->socket_factory->AddSocketDataProvider(&data);
|
| +
|
| + TestCompletionCallback callback;
|
| +
|
| + int rv = trans.Start(&request, callback.callback(), NetLogWithSource());
|
| + EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
|
| +
|
| + rv = callback.WaitForResult();
|
| + if (should_match) {
|
| + EXPECT_THAT(rv, IsOk());
|
| + } else {
|
| + EXPECT_THAT(rv, IsError(ERR_INVALID_CONTENT_ENCODING));
|
| + }
|
| +}
|
| +
|
| +TEST_F(HttpNetworkTransactionTest, MatchContentEncoding1) {
|
| + CheckContentEncodingMatching(&session_deps_, "foo", "foo", true);
|
| +}
|
| +
|
| +TEST_F(HttpNetworkTransactionTest, MatchContentEncoding2) {
|
| + CheckContentEncodingMatching(&session_deps_, "foo", "food", false);
|
| +}
|
| +
|
| +TEST_F(HttpNetworkTransactionTest, MatchContentEncoding3) {
|
| + CheckContentEncodingMatching(&session_deps_, "gzip", "x-gzip", true);
|
| +}
|
| +
|
| +TEST_F(HttpNetworkTransactionTest, MatchContentEncoding4) {
|
| + CheckContentEncodingMatching(&session_deps_, "foo,bar", "foo", true);
|
| +}
|
| +
|
| +TEST_F(HttpNetworkTransactionTest, MatchContentEncoding5) {
|
| + CheckContentEncodingMatching(&session_deps_, "foo,bar", "bar", true);
|
| +}
|
| +
|
| +TEST_F(HttpNetworkTransactionTest, MatchContentEncoding6) {
|
| + CheckContentEncodingMatching(&session_deps_, "bar; q=0", "bar", false);
|
| +}
|
| +
|
| +TEST_F(HttpNetworkTransactionTest, MatchContentEncoding7) {
|
| + CheckContentEncodingMatching(&session_deps_, "bar; q=0.000", "bar", false);
|
| +}
|
| +
|
| +TEST_F(HttpNetworkTransactionTest, MatchContentEncoding8) {
|
| + CheckContentEncodingMatching(&session_deps_, "bar; q=0.001", "bar", true);
|
| +}
|
| +
|
| +TEST_F(HttpNetworkTransactionTest, MatchContentEncoding9) {
|
| + CheckContentEncodingMatching(&session_deps_, "bar; q=1", "bar", true);
|
| +}
|
| +
|
| +TEST_F(HttpNetworkTransactionTest, MatchContentEncodingA) {
|
| + CheckContentEncodingMatching(&session_deps_, "bar; q=0,foo", "bar", false);
|
| +}
|
| +
|
| } // namespace net
|
|
|