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

Side by Side Diff: net/http/http_response_headers_unittest.cc

Issue 527883002: Modified to resolve TODO in parseversion in http_response_headers.cc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Modified to include overflow logic and other comments Created 6 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 unified diff | Download patch
« no previous file with comments | « net/http/http_response_headers.cc ('k') | net/http/http_version.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <algorithm> 5 #include <algorithm>
6 #include <limits> 6 #include <limits>
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/pickle.h" 10 #include "base/pickle.h"
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 186
187 "hTtP/0.9 200 OK\n", 187 "hTtP/0.9 200 OK\n",
188 188
189 "HTTP/0.9 200 OK\n", 189 "HTTP/0.9 200 OK\n",
190 190
191 200, 191 200,
192 net::HttpVersion(0,9), 192 net::HttpVersion(0,9),
193 net::HttpVersion(0,9) 193 net::HttpVersion(0,9)
194 }, 194 },
195 { 195 {
196 // Test for Leading zeros in http version
197
198 "HTTP/01.1 200 OK\n",
199
200 "HTTP/1.1 200 OK\n",
201
202 200,
203 net::HttpVersion(1, 1),
204 net::HttpVersion(1, 1)
205 },
206 {
207 // Test for Leading zeros in http version
208
209 "HTTP/0001.1 200 OK\n",
210
211 "HTTP/1.1 200 OK\n",
212
213 200,
214 net::HttpVersion(1, 1),
215 net::HttpVersion(1, 1)
216 },
217 {
218 // Test for Leading zeros in http version
219
220 "HTTP/10.1 200 OK\n",
221
222 "HTTP/10.1 200 OK\n",
223
224 200,
225 net::HttpVersion(10, 1),
226 net::HttpVersion(10, 1)
227 },
228 {
229 // Test for Leading zeros in http version
230
231 "HTTP/1.01 200 OK\n",
232
233 "HTTP/1.1 200 OK\n",
234
235 200,
236 net::HttpVersion(1, 1),
237 net::HttpVersion(1, 1)
238 },
239 {
240 // Test for multiple digits in http version
241
242 "HTTP/21.1 200 OK\n",
243
244 "HTTP/21.1 200 OK\n",
245
246 200,
247
248 net::HttpVersion(21, 1),
249 net::HttpVersion(21, 1)
250 },
251 {
252 // Test for multiple digits in http version
253
254 "HTTP/1.21 200 OK\n",
255
256 "HTTP/1.21 200 OK\n",
257
258 200,
259 net::HttpVersion(1, 21),
260 net::HttpVersion(1, 21)
261 },
262 {
263 // Test for multiple digits in http version
264
265 "HTTP/21.21 200 OK\n",
266
267 "HTTP/21.21 200 OK\n",
268
269 200,
270 net::HttpVersion(21, 21),
271 net::HttpVersion(21, 21)
272 },
273 {
274 // Test for multiple digits in http version
275
276 "HTTP/221.21 200 OK\n",
277
278 "HTTP/221.21 200 OK\n",
279
280 200,
281 net::HttpVersion(221, 21),
282 net::HttpVersion(221, 21)
283 },
284 {
285 // Test for http version overflow
286
287 "HTTP/231342424423424.21 200 OK\n",
288
289 "HTTP/1.0 200 OK\n",
290
291 200,
292 net::HttpVersion(0, 0),
293 net::HttpVersion(1, 0)
294 },
295 {
296 // Test for http version underflow
297
298 "HTTP/23.-21 200 OK\n",
299
300 "HTTP/1.0 200 OK\n",
301
302 200,
303 net::HttpVersion(0, 0),
304 net::HttpVersion(1, 0)
305 },
306 {
307 // Test for non-numeric chars in http version
308
309 "HTTP/341a.23 200 OK\n",
310
311 "HTTP/1.0 200 OK\n",
312
313 200,
314 net::HttpVersion(0, 0),
315 net::HttpVersion(1, 0)
316 },
317 {
318 // Test for non-numeric chars in http version
319
320 "HTTP/341.23a 200 OK\n",
321
322 "HTTP/1.0 200 OK\n",
323
324 200,
325 net::HttpVersion(0, 0),
326 net::HttpVersion(1, 0)
327 },
328 {
329 // Test for non-numeric chars in http version
330
331 "HTTP/341a.23a 200 OK\n",
332
333 "HTTP/1.0 200 OK\n",
334
335 200,
336 net::HttpVersion(0, 0),
337 net::HttpVersion(1, 0)
338 },
339 {
340 // Test for non-numeric chars in http version
341
342 "HTTP/a341.23 200 OK\n",
343
344 "HTTP/1.0 200 OK\n",
345
346 200,
347 net::HttpVersion(0, 0),
348 net::HttpVersion(1, 0)
349 },
350 {
351 // Test for non-numeric chars in http version
352
353 "HTTP/341.a23 200 OK\n",
354
355 "HTTP/1.0 200 OK\n",
356
357 200,
358 net::HttpVersion(0, 0),
359 net::HttpVersion(1, 0)
360 },
361 {
362 // Test for non-numeric chars in http version
363
364 "HTTP/a341.a23 200 OK\n",
365
366 "HTTP/1.0 200 OK\n",
367
368 200,
369 net::HttpVersion(0, 0),
370 net::HttpVersion(1, 0)
371 },
372 {
373 // Test for non-numeric chars in http version
374
375 "HTTP/34a1.2a3 200 OK\n",
376
377 "HTTP/1.0 200 OK\n",
378
379 200,
380 net::HttpVersion(0, 0),
381 net::HttpVersion(1, 0)
382 },
383 {
384 // Test for empty major and minor value in http version
385
386 "HTTP/. 200 OK\n",
387
388 "HTTP/1.0 200 OK\n",
389
390 200,
391 net::HttpVersion(0, 0),
392 net::HttpVersion(1, 0)
393 },
394 {
395 // Test for empty major value in http version
396
397 "HTTP/.23 200 OK\n",
398
399 "HTTP/1.0 200 OK\n",
400
401 200,
402 net::HttpVersion(0, 0),
403 net::HttpVersion(1, 0)
404 },
405 {
406 // Test for empty minor value in http version
407
408 "HTTP/341. 200 OK\n",
409
410 "HTTP/1.0 200 OK\n",
411
412 200,
413 net::HttpVersion(0, 0),
414 net::HttpVersion(1, 0)
415 },
416 {
417 // Test for empty http version
418
419 "HTTP/ 200 OK\n",
420
421 "HTTP/1.0 200 OK\n",
422
423 200,
424 net::HttpVersion(0, 0),
425 net::HttpVersion(1, 0)
426 },
427 {
196 // Add missing OK. 428 // Add missing OK.
197 429
198 "HTTP/1.1 201\n" 430 "HTTP/1.1 201\n"
199 "Content-TYPE: text/html; charset=utf-8\n", 431 "Content-TYPE: text/html; charset=utf-8\n",
200 432
201 "HTTP/1.1 201 OK\n" 433 "HTTP/1.1 201 OK\n"
202 "Content-TYPE: text/html; charset=utf-8\n", 434 "Content-TYPE: text/html; charset=utf-8\n",
203 435
204 201, 436 201,
205 net::HttpVersion(1,1), 437 net::HttpVersion(1,1),
(...skipping 2041 matching lines...) Expand 10 before | Expand all | Expand 10 after
2247 } 2479 }
2248 2480
2249 TEST_F(HttpResponseHeadersCacheControlTest, 2481 TEST_F(HttpResponseHeadersCacheControlTest,
2250 FirstStaleWhileRevalidateValueUsed) { 2482 FirstStaleWhileRevalidateValueUsed) {
2251 InitializeHeadersWithCacheControl( 2483 InitializeHeadersWithCacheControl(
2252 "stale-while-revalidate=1,stale-while-revalidate=7200"); 2484 "stale-while-revalidate=1,stale-while-revalidate=7200");
2253 EXPECT_EQ(TimeDelta::FromSeconds(1), GetStaleWhileRevalidateValue()); 2485 EXPECT_EQ(TimeDelta::FromSeconds(1), GetStaleWhileRevalidateValue());
2254 } 2486 }
2255 2487
2256 } // end namespace 2488 } // end namespace
OLDNEW
« no previous file with comments | « net/http/http_response_headers.cc ('k') | net/http/http_version.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698