Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2269)

Unified Diff: net/url_request/report_sender.cc

Issue 2365353004: Add Content-Type header to net::ReportSender reports (Closed)
Patch Set: eroman comment Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/url_request/report_sender.h ('k') | net/url_request/report_sender_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/url_request/report_sender.cc
diff --git a/net/url_request/report_sender.cc b/net/url_request/report_sender.cc
index 76f171d116a7e68fd19911b0edeace9d99f3ff5a..16503608f9c4354f5b807135b909b57ddd149a48 100644
--- a/net/url_request/report_sender.cc
+++ b/net/url_request/report_sender.cc
@@ -32,7 +32,10 @@ ReportSender::~ReportSender() {
base::STLDeleteElements(&inflight_requests_);
}
-void ReportSender::Send(const GURL& report_uri, const std::string& report) {
+void ReportSender::Send(const GURL& report_uri,
+ base::StringPiece content_type,
+ base::StringPiece report) {
+ DCHECK(!content_type.empty());
std::unique_ptr<URLRequest> url_request =
request_context_->CreateRequest(report_uri, DEFAULT_PRIORITY, this);
@@ -43,10 +46,15 @@ void ReportSender::Send(const GURL& report_uri, const std::string& report) {
}
url_request->SetLoadFlags(load_flags);
+ HttpRequestHeaders extra_headers;
+ extra_headers.SetHeader(HttpRequestHeaders::kContentType, content_type);
+ url_request->SetExtraRequestHeaders(extra_headers);
+
url_request->set_method("POST");
+ std::vector<char> report_data(report.begin(), report.end());
std::unique_ptr<UploadElementReader> reader(
- UploadOwnedBytesElementReader::CreateWithString(report));
+ new UploadOwnedBytesElementReader(&report_data));
url_request->set_upload(
ElementsUploadDataStream::CreateWithReader(std::move(reader), 0));
« no previous file with comments | « net/url_request/report_sender.h ('k') | net/url_request/report_sender_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698