2018-10-24 18:24:11 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Jeremy Apthorp <nornagon@nornagon.net>
|
|
|
|
Date: Thu, 18 Oct 2018 17:06:46 -0700
|
|
|
|
Subject: crashpad_http_status.patch
|
|
|
|
|
|
|
|
backport of crashpad f540abb506
|
|
|
|
|
2018-09-14 18:03:43 +00:00
|
|
|
diff --git a/third_party/crashpad/crashpad/util/net/http_transport.h b/third_party/crashpad/crashpad/util/net/http_transport.h
|
2018-10-24 18:24:11 +00:00
|
|
|
index f91a55612a2ffc2f4a78ff48ceba6174adc58cbf..acd4e442462b031dd304f303cdaa3664f5cffb64 100644
|
2018-09-14 18:03:43 +00:00
|
|
|
--- a/third_party/crashpad/crashpad/util/net/http_transport.h
|
|
|
|
+++ b/third_party/crashpad/crashpad/util/net/http_transport.h
|
2018-10-24 18:24:11 +00:00
|
|
|
@@ -90,7 +90,7 @@ class HTTPTransport {
|
2018-09-14 18:03:43 +00:00
|
|
|
//! if the response body is not required.
|
|
|
|
//!
|
|
|
|
//! \return Whether or not the request was successful, defined as returning
|
|
|
|
- //! a HTTP status 200 (OK) code.
|
|
|
|
+ //! a HTTP status code in the range 200-203 (inclusive).
|
|
|
|
virtual bool ExecuteSynchronously(std::string* response_body) = 0;
|
2018-09-14 05:02:16 +00:00
|
|
|
|
2018-09-14 18:03:43 +00:00
|
|
|
protected:
|
2018-09-14 05:02:16 +00:00
|
|
|
diff --git a/third_party/crashpad/crashpad/util/net/http_transport_mac.mm b/third_party/crashpad/crashpad/util/net/http_transport_mac.mm
|
2018-10-24 18:24:11 +00:00
|
|
|
index 8d5f78cc6efc8b8e349958f51c78921a8c163c4e..a433bb357da5865144ade7d3663b1c9b36199f8e 100644
|
2018-09-14 05:02:16 +00:00
|
|
|
--- a/third_party/crashpad/crashpad/util/net/http_transport_mac.mm
|
|
|
|
+++ b/third_party/crashpad/crashpad/util/net/http_transport_mac.mm
|
2018-10-24 18:24:11 +00:00
|
|
|
@@ -293,7 +293,7 @@ bool HTTPTransportMac::ExecuteSynchronously(std::string* response_body) {
|
2018-09-14 05:02:16 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
NSInteger http_status = [http_response statusCode];
|
|
|
|
- if (http_status != 200) {
|
2018-09-14 18:03:43 +00:00
|
|
|
+ if (http_status < 200 || http_status > 203) {
|
2018-09-14 05:02:16 +00:00
|
|
|
LOG(ERROR) << base::StringPrintf("HTTP status %ld",
|
|
|
|
implicit_cast<long>(http_status));
|
|
|
|
return false;
|
2018-09-14 18:03:43 +00:00
|
|
|
diff --git a/third_party/crashpad/crashpad/util/net/http_transport_socket.cc b/third_party/crashpad/crashpad/util/net/http_transport_socket.cc
|
2018-10-24 18:24:11 +00:00
|
|
|
index f0e2dc14a8a487b5960d700be57100c9bed4f271..34d8deeb5c25f6b49fd0acadce67a3816869d3da 100644
|
2018-09-14 18:03:43 +00:00
|
|
|
--- a/third_party/crashpad/crashpad/util/net/http_transport_socket.cc
|
|
|
|
+++ b/third_party/crashpad/crashpad/util/net/http_transport_socket.cc
|
2018-09-21 00:30:26 +00:00
|
|
|
@@ -457,10 +457,18 @@ bool ReadResponseLine(Stream* stream) {
|
2018-09-14 18:03:43 +00:00
|
|
|
LOG(ERROR) << "ReadLine";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
- static constexpr const char kHttp10[] = "HTTP/1.0 200 ";
|
|
|
|
- static constexpr const char kHttp11[] = "HTTP/1.1 200 ";
|
|
|
|
- return StartsWith(response_line, kHttp10, strlen(kHttp10)) ||
|
|
|
|
- StartsWith(response_line, kHttp11, strlen(kHttp11));
|
|
|
|
+ static constexpr const char kHttp10[] = "HTTP/1.0 ";
|
|
|
|
+ static constexpr const char kHttp11[] = "HTTP/1.1 ";
|
|
|
|
+ if (!(StartsWith(response_line, kHttp10, strlen(kHttp10)) ||
|
|
|
|
+ StartsWith(response_line, kHttp11, strlen(kHttp11))) ||
|
|
|
|
+ response_line.size() < strlen(kHttp10) + 3 ||
|
|
|
|
+ response_line.at(strlen(kHttp10) + 3) != ' ') {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ unsigned int http_status = 0;
|
|
|
|
+ return base::StringToUint(response_line.substr(strlen(kHttp10), 3),
|
|
|
|
+ &http_status) &&
|
|
|
|
+ http_status >= 200 && http_status <= 203;
|
|
|
|
}
|
2018-10-24 18:24:11 +00:00
|
|
|
|
2018-09-21 00:30:26 +00:00
|
|
|
bool ReadResponseHeaders(Stream* stream, HTTPHeaders* headers) {
|
2018-09-14 18:03:43 +00:00
|
|
|
diff --git a/third_party/crashpad/crashpad/util/net/http_transport_test.cc b/third_party/crashpad/crashpad/util/net/http_transport_test.cc
|
2018-10-24 18:24:11 +00:00
|
|
|
index 7b5f41dfd1e18b212d7dd349cff8f4396e20dbc3..d73dc99217e08f7c84ded50868cbef02141a6b9b 100644
|
2018-09-14 18:03:43 +00:00
|
|
|
--- a/third_party/crashpad/crashpad/util/net/http_transport_test.cc
|
|
|
|
+++ b/third_party/crashpad/crashpad/util/net/http_transport_test.cc
|
2018-10-24 18:24:11 +00:00
|
|
|
@@ -137,7 +137,7 @@ class HTTPTransportTestFixture : public MultiprocessExec {
|
2018-09-14 18:03:43 +00:00
|
|
|
|
|
|
|
std::string response_body;
|
|
|
|
bool success = transport->ExecuteSynchronously(&response_body);
|
|
|
|
- if (response_code_ == 200) {
|
|
|
|
+ if (response_code_ >= 200 && response_code_ <= 203) {
|
|
|
|
EXPECT_TRUE(success);
|
|
|
|
std::string expect_response_body = random_string + "\r\n";
|
|
|
|
EXPECT_EQ(response_body, expect_response_body);
|
2018-09-14 05:02:16 +00:00
|
|
|
diff --git a/third_party/crashpad/crashpad/util/net/http_transport_win.cc b/third_party/crashpad/crashpad/util/net/http_transport_win.cc
|
2018-10-24 18:24:11 +00:00
|
|
|
index 18d343ccef0396ee6679f4b5fd8316c3109003f4..2919bc11d0ba4bf84a11e146bf2961b830db35fe 100644
|
2018-09-14 05:02:16 +00:00
|
|
|
--- a/third_party/crashpad/crashpad/util/net/http_transport_win.cc
|
|
|
|
+++ b/third_party/crashpad/crashpad/util/net/http_transport_win.cc
|
2018-10-24 18:24:11 +00:00
|
|
|
@@ -375,7 +375,7 @@ bool HTTPTransportWin::ExecuteSynchronously(std::string* response_body) {
|
2018-09-14 05:02:16 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
- if (status_code != 200) {
|
2018-09-14 18:03:43 +00:00
|
|
|
+ if (status_code < 200 || status_code > 203) {
|
2018-09-14 05:02:16 +00:00
|
|
|
LOG(ERROR) << base::StringPrintf("HTTP status %lu", status_code);
|
|
|
|
return false;
|
|
|
|
}
|