Chromium Code Reviews| 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..2cc6cb383cd4412a37b0af8d50c547892ffc4e01 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()); |
|
Nathan Parker
2016/09/26 23:53:25
Can you DCHECK that content_type is a probably-val
eroman
2016/09/27 00:03:34
Or if JSON and application/octet-stream are going
estark
2016/09/27 04:05:20
I like the enum idea, but I can't figure out how t
|
| std::unique_ptr<URLRequest> url_request = |
| request_context_->CreateRequest(report_uri, DEFAULT_PRIORITY, this); |
| @@ -43,10 +46,14 @@ 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::unique_ptr<UploadElementReader> reader( |
| - UploadOwnedBytesElementReader::CreateWithString(report)); |
| + std::unique_ptr<UploadElementReader> reader(new UploadOwnedBytesElementReader( |
| + new std::vector<char>(report.data(), report.data() + report.length()))); |
|
eroman
2016/09/26 23:40:55
nit: For terser code: (report.begin(), report.end(
estark
2016/09/27 04:05:20
Done.
|
| url_request->set_upload( |
| ElementsUploadDataStream::CreateWithReader(std::move(reader), 0)); |