OLD | NEW |
---|---|
1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
271 | 271 |
272 HTTPHeaders headers; | 272 HTTPHeaders headers; |
273 headers[kContentType] = kTextPlain; | 273 headers[kContentType] = kTextPlain; |
274 headers[kContentLength] = base::StringPrintf("%" PRIuS, strlen(kTextBody)); | 274 headers[kContentLength] = base::StringPrintf("%" PRIuS, strlen(kTextBody)); |
275 | 275 |
276 HTTPTransportTestFixture test(headers, body_stream.Pass(), 200, | 276 HTTPTransportTestFixture test(headers, body_stream.Pass(), 200, |
277 &UnchunkedPlainText); | 277 &UnchunkedPlainText); |
278 test.Run(); | 278 test.Run(); |
279 } | 279 } |
280 | 280 |
281 TEST(HTTPTransport, Upload33k) { | |
282 // NSMutableURLRequest winds up calling into a CFReadStream’s Read() callback | |
283 // with a 32kB buffer. Make sure that it’s able to get everything when enough | |
284 // is available to fill this buffer, requiring more than one Read(). | |
285 | |
286 std::string request_string(33 * 1024, 'a'); | |
287 scoped_ptr<HTTPBodyStream> body_stream( | |
288 new StringHTTPBodyStream(request_string)); | |
289 | |
290 HTTPHeaders headers; | |
291 headers[kContentType] = "application/octet-stream"; | |
292 headers[kContentLength] = base::StringPrintf("%zu", request_string.size()); | |
Robert Sesek
2015/08/18 19:35:07
PRIuS instead of %zu.
| |
293 HTTPTransportTestFixture test(headers, body_stream.Pass(), 200, | |
294 [](HTTPTransportTestFixture* fixture, const std::string& request) { | |
295 size_t body_start = request.rfind("\r\n"); | |
296 EXPECT_EQ(33 * 1024u + 2, request.size() - body_start); | |
297 }); | |
298 test.Run(); | |
299 } | |
300 | |
281 } // namespace | 301 } // namespace |
282 } // namespace test | 302 } // namespace test |
283 } // namespace crashpad | 303 } // namespace crashpad |
OLD | NEW |