cherry-pick.v2.9.4-7-g4b99e42.test-content-length-header-parsing.patch 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  1. Subject: Test Content-Length header parsing
  2. Origin: v2.9.4-7-g4b99e42 <https://github.com/joyent/http-parser/commit/4b99e42>
  3. Upstream-Author: Ben Noordhuis <info@bnoordhuis.nl>
  4. Date: Wed Jul 8 02:30:29 2020 +0200
  5. The test suite did very little validation of the Content-Length field
  6. until now. Verify for each request and response that the parsed numeric
  7. value matches the value from the header field.
  8. PR-URL: https://github.com/nodejs/http-parser/pull/519
  9. Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
  10. --- a/test.c
  11. +++ b/test.c
  12. @@ -74,6 +74,7 @@
  13. unsigned short http_major;
  14. unsigned short http_minor;
  15. + uint64_t content_length;
  16. int message_begin_cb_called;
  17. int headers_complete_cb_called;
  18. @@ -108,6 +109,7 @@
  19. ,.fragment= ""
  20. ,.request_path= "/test"
  21. ,.request_url= "/test"
  22. + ,.content_length= -1
  23. ,.num_headers= 3
  24. ,.headers=
  25. { { "User-Agent", "curl/7.18.0 (i486-pc-linux-gnu) libcurl/7.18.0 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.1" }
  26. @@ -139,6 +141,7 @@
  27. ,.fragment= ""
  28. ,.request_path= "/favicon.ico"
  29. ,.request_url= "/favicon.ico"
  30. + ,.content_length= -1
  31. ,.num_headers= 8
  32. ,.headers=
  33. { { "Host", "0.0.0.0=5000" }
  34. @@ -168,6 +171,7 @@
  35. ,.fragment= ""
  36. ,.request_path= "/dumbluck"
  37. ,.request_url= "/dumbluck"
  38. + ,.content_length= -1
  39. ,.num_headers= 1
  40. ,.headers=
  41. { { "aaaaaaaaaaaaa", "++++++++++" }
  42. @@ -190,6 +194,7 @@
  43. ,.request_path= "/forums/1/topics/2375"
  44. /* XXX request url does include fragment? */
  45. ,.request_url= "/forums/1/topics/2375?page=1#posts-17408"
  46. + ,.content_length= -1
  47. ,.num_headers= 0
  48. ,.body= ""
  49. }
  50. @@ -208,6 +213,7 @@
  51. ,.fragment= ""
  52. ,.request_path= "/get_no_headers_no_body/world"
  53. ,.request_url= "/get_no_headers_no_body/world"
  54. + ,.content_length= -1
  55. ,.num_headers= 0
  56. ,.body= ""
  57. }
  58. @@ -227,6 +233,7 @@
  59. ,.fragment= ""
  60. ,.request_path= "/get_one_header_no_body"
  61. ,.request_url= "/get_one_header_no_body"
  62. + ,.content_length= -1
  63. ,.num_headers= 1
  64. ,.headers=
  65. { { "Accept" , "*/*" }
  66. @@ -250,6 +257,7 @@
  67. ,.fragment= ""
  68. ,.request_path= "/get_funky_content_length_body_hello"
  69. ,.request_url= "/get_funky_content_length_body_hello"
  70. + ,.content_length= 5
  71. ,.num_headers= 1
  72. ,.headers=
  73. { { "conTENT-Length" , "5" }
  74. @@ -274,6 +282,7 @@
  75. ,.fragment= "hey"
  76. ,.request_path= "/post_identity_body_world"
  77. ,.request_url= "/post_identity_body_world?q=search#hey"
  78. + ,.content_length= 5
  79. ,.num_headers= 2
  80. ,.headers=
  81. { { "Accept", "*/*" }
  82. @@ -300,6 +309,7 @@
  83. ,.fragment= ""
  84. ,.request_path= "/post_chunked_all_your_base"
  85. ,.request_url= "/post_chunked_all_your_base"
  86. + ,.content_length= -1
  87. ,.num_headers= 1
  88. ,.headers=
  89. { { "Transfer-Encoding" , "chunked" }
  90. @@ -328,6 +338,7 @@
  91. ,.fragment= ""
  92. ,.request_path= "/two_chunks_mult_zero_end"
  93. ,.request_url= "/two_chunks_mult_zero_end"
  94. + ,.content_length= -1
  95. ,.num_headers= 1
  96. ,.headers=
  97. { { "Transfer-Encoding", "chunked" }
  98. @@ -358,6 +369,7 @@
  99. ,.fragment= ""
  100. ,.request_path= "/chunked_w_trailing_headers"
  101. ,.request_url= "/chunked_w_trailing_headers"
  102. + ,.content_length= -1
  103. ,.num_headers= 3
  104. ,.headers=
  105. { { "Transfer-Encoding", "chunked" }
  106. @@ -388,6 +400,7 @@
  107. ,.fragment= ""
  108. ,.request_path= "/chunked_w_nonsense_after_length"
  109. ,.request_url= "/chunked_w_nonsense_after_length"
  110. + ,.content_length= -1
  111. ,.num_headers= 1
  112. ,.headers=
  113. { { "Transfer-Encoding", "chunked" }
  114. @@ -410,6 +423,7 @@
  115. ,.fragment= ""
  116. ,.request_path= "/with_\"stupid\"_quotes"
  117. ,.request_url= "/with_\"stupid\"_quotes?foo=\"bar\""
  118. + ,.content_length= -1
  119. ,.num_headers= 0
  120. ,.headers= { }
  121. ,.body= ""
  122. @@ -436,6 +450,7 @@
  123. ,.fragment= ""
  124. ,.request_path= "/test"
  125. ,.request_url= "/test"
  126. + ,.content_length= -1
  127. ,.num_headers= 3
  128. ,.headers= { { "Host", "0.0.0.0:5000" }
  129. , { "User-Agent", "ApacheBench/2.3" }
  130. @@ -459,6 +474,7 @@
  131. ,.fragment= ""
  132. ,.request_path= "/test.cgi"
  133. ,.request_url= "/test.cgi?foo=bar?baz"
  134. + ,.content_length= -1
  135. ,.num_headers= 0
  136. ,.headers= {}
  137. ,.body= ""
  138. @@ -480,6 +496,7 @@
  139. ,.fragment= ""
  140. ,.request_path= "/test"
  141. ,.request_url= "/test"
  142. + ,.content_length= -1
  143. ,.num_headers= 0
  144. ,.headers= { }
  145. ,.body= ""
  146. @@ -507,6 +524,7 @@
  147. ,.fragment= ""
  148. ,.request_path= "/demo"
  149. ,.request_url= "/demo"
  150. + ,.content_length= -1
  151. ,.num_headers= 7
  152. ,.upgrade="Hot diggity dogg"
  153. ,.headers= { { "Host", "example.com" }
  154. @@ -538,6 +556,7 @@
  155. ,.fragment= ""
  156. ,.request_path= ""
  157. ,.request_url= "0-home0.netscape.com:443"
  158. + ,.content_length= -1
  159. ,.num_headers= 2
  160. ,.upgrade="some data\r\nand yet even more data"
  161. ,.headers= { { "User-agent", "Mozilla/1.1N" }
  162. @@ -560,6 +579,7 @@
  163. ,.fragment= ""
  164. ,.request_path= "/test"
  165. ,.request_url= "/test"
  166. + ,.content_length= -1
  167. ,.num_headers= 0
  168. ,.headers= {}
  169. ,.body= ""
  170. @@ -579,6 +599,7 @@
  171. ,.fragment= ""
  172. ,.request_path= "/"
  173. ,.request_url= "/"
  174. + ,.content_length= -1
  175. ,.num_headers= 0
  176. ,.headers= {}
  177. ,.body= ""
  178. @@ -601,6 +622,7 @@
  179. ,.fragment= ""
  180. ,.request_path= "*"
  181. ,.request_url= "*"
  182. + ,.content_length= -1
  183. ,.num_headers= 3
  184. ,.headers= { { "HOST", "239.255.255.250:1900" }
  185. , { "MAN", "\"ssdp:discover\"" }
  186. @@ -636,6 +658,7 @@
  187. ,.fragment= ""
  188. ,.request_path= "/"
  189. ,.request_url= "/"
  190. + ,.content_length= -1
  191. ,.num_headers= 5
  192. ,.headers= { { "Line1", "abc\tdef ghi\t\tjkl mno \t \tqrs" }
  193. , { "Line2", "line2\t" }
  194. @@ -662,6 +685,7 @@
  195. ,.request_path= ""
  196. ,.request_url= "http://hypnotoad.org?hail=all"
  197. ,.host= "hypnotoad.org"
  198. + ,.content_length= -1
  199. ,.num_headers= 0
  200. ,.headers= { }
  201. ,.body= ""
  202. @@ -683,6 +707,7 @@
  203. ,.request_url= "http://hypnotoad.org:1234?hail=all"
  204. ,.host= "hypnotoad.org"
  205. ,.port= 1234
  206. + ,.content_length= -1
  207. ,.num_headers= 0
  208. ,.headers= { }
  209. ,.body= ""
  210. @@ -704,6 +729,7 @@
  211. ,.request_url= "http://hypnotoad.org:1234"
  212. ,.host= "hypnotoad.org"
  213. ,.port= 1234
  214. + ,.content_length= -1
  215. ,.num_headers= 0
  216. ,.headers= { }
  217. ,.body= ""
  218. @@ -728,6 +754,7 @@
  219. ,.fragment= ""
  220. ,.request_path= "/file.txt"
  221. ,.request_url= "/file.txt"
  222. + ,.content_length= 10
  223. ,.num_headers= 4
  224. ,.headers= { { "Host", "www.example.com" }
  225. , { "Content-Type", "application/example" }
  226. @@ -753,6 +780,7 @@
  227. ,.fragment= ""
  228. ,.request_path= ""
  229. ,.request_url= "HOME0.NETSCAPE.COM:443"
  230. + ,.content_length= -1
  231. ,.num_headers= 2
  232. ,.upgrade=""
  233. ,.headers= { { "User-agent", "Mozilla/1.1N" }
  234. @@ -777,6 +805,7 @@
  235. ,.fragment= "narf"
  236. ,.request_path= "/δ¶/δt/pope"
  237. ,.request_url= "/δ¶/δt/pope?q=1#narf"
  238. + ,.content_length= -1
  239. ,.num_headers= 1
  240. ,.headers= { {"Host", "github.com" }
  241. }
  242. @@ -799,6 +828,7 @@
  243. ,.fragment= ""
  244. ,.request_path= ""
  245. ,.request_url= "home_0.netscape.com:443"
  246. + ,.content_length= -1
  247. ,.num_headers= 2
  248. ,.upgrade=""
  249. ,.headers= { { "User-agent", "Mozilla/1.1N" }
  250. @@ -826,6 +856,7 @@
  251. ,.fragment= ""
  252. ,.request_path= "/"
  253. ,.request_url= "/"
  254. + ,.content_length= 4
  255. ,.num_headers= 3
  256. ,.upgrade= 0
  257. ,.headers= { { "Host", "www.example.com" }
  258. @@ -854,6 +885,7 @@
  259. ,.fragment= ""
  260. ,.request_path= "/"
  261. ,.request_url= "/"
  262. + ,.content_length= 4
  263. ,.num_headers= 4
  264. ,.upgrade= 0
  265. ,.headers= { { "Host", "www.example.com" }
  266. @@ -879,6 +911,7 @@
  267. ,.fragment= ""
  268. ,.request_path= "/file.txt"
  269. ,.request_url= "/file.txt"
  270. + ,.content_length= -1
  271. ,.num_headers= 1
  272. ,.headers= { { "Host", "www.example.com" } }
  273. ,.body= ""
  274. @@ -899,6 +932,7 @@
  275. ,.fragment= ""
  276. ,.request_path= "/"
  277. ,.request_url= "/"
  278. + ,.content_length= -1
  279. ,.num_headers= 1
  280. ,.headers= { { "Host", "www.example.com" } }
  281. ,.body= ""
  282. @@ -920,6 +954,7 @@
  283. ,.host= "hypnotoad.org"
  284. ,.userinfo= "a%12:b!&*$"
  285. ,.port= 1234
  286. + ,.content_length= -1
  287. ,.num_headers= 0
  288. ,.headers= { }
  289. ,.body= ""
  290. @@ -952,6 +987,7 @@
  291. ,.fragment= ""
  292. ,.request_path= "/"
  293. ,.request_url= "/"
  294. + ,.content_length= -1
  295. ,.num_headers= 5
  296. ,.headers= { { "Line1", "abc\tdef ghi\t\tjkl mno \t \tqrs" }
  297. , { "Line2", "line2\t" }
  298. @@ -985,6 +1021,7 @@
  299. ,.fragment= ""
  300. ,.request_path= "/demo"
  301. ,.request_url= "/demo"
  302. + ,.content_length= -1
  303. ,.num_headers= 7
  304. ,.upgrade="Hot diggity dogg"
  305. ,.headers= { { "Host", "example.com" }
  306. @@ -1015,6 +1052,7 @@
  307. ,.fragment= ""
  308. ,.request_path= "/demo"
  309. ,.request_url= "/demo"
  310. + ,.content_length= -1
  311. ,.num_headers= 2
  312. ,.upgrade="Hot diggity dogg"
  313. ,.headers= { { "Connection", "keep-alive, upgrade" }
  314. @@ -1040,6 +1078,7 @@
  315. ,.fragment= ""
  316. ,.request_path= "/demo"
  317. ,.request_url= "/demo"
  318. + ,.content_length= -1
  319. ,.num_headers= 2
  320. ,.upgrade="Hot diggity dogg"
  321. ,.headers= { { "Connection", "keep-alive, upgrade" }
  322. @@ -1066,6 +1105,7 @@
  323. ,.method= HTTP_POST
  324. ,.request_path= "/demo"
  325. ,.request_url= "/demo"
  326. + ,.content_length= 15
  327. ,.num_headers= 4
  328. ,.upgrade="Hot diggity dogg"
  329. ,.headers= { { "Host", "example.com" }
  330. @@ -1091,6 +1131,7 @@
  331. ,.http_minor= 0
  332. ,.method= HTTP_CONNECT
  333. ,.request_url= "foo.bar.com:443"
  334. + ,.content_length= 10
  335. ,.num_headers= 3
  336. ,.upgrade="blarfcicle"
  337. ,.headers= { { "User-agent", "Mozilla/1.1N" }
  338. @@ -1121,6 +1162,7 @@
  339. ,.request_url= "/images/my_dog.jpg"
  340. ,.query_string= ""
  341. ,.fragment= ""
  342. + ,.content_length= -1
  343. ,.num_headers= 3
  344. ,.headers= { { "Host", "example.com" }
  345. , { "Link", "<http://example.com/profiles/joe>; rel=\"tag\"" }
  346. @@ -1145,6 +1187,7 @@
  347. ,.request_url= "/images/my_dog.jpg"
  348. ,.query_string= ""
  349. ,.fragment= ""
  350. + ,.content_length= -1
  351. ,.num_headers= 2
  352. ,.headers= { { "Host", "example.com" }
  353. , { "Link", "<http://example.com/profiles/sally>; rel=\"tag\"" }
  354. @@ -1167,6 +1210,7 @@
  355. ,.request_url= "/music/sweet/music"
  356. ,.query_string= ""
  357. ,.fragment= ""
  358. + ,.content_length= -1
  359. ,.num_headers= 1
  360. ,.headers= { { "Host", "example.com" } }
  361. ,.body= ""
  362. @@ -1187,6 +1231,7 @@
  363. ,.request_url= "/music/sweet/music"
  364. ,.query_string= ""
  365. ,.fragment= ""
  366. + ,.content_length= -1
  367. ,.num_headers= 1
  368. ,.headers= { { "Host", "example.com" } }
  369. ,.body= ""
  370. @@ -1210,6 +1255,7 @@
  371. ,.fragment= ""
  372. ,.request_path= "/"
  373. ,.request_url= "/"
  374. + ,.content_length= -1
  375. ,.num_headers= 1
  376. ,.headers=
  377. { { "Transfer-Encoding" , "deflate, chunked" }
  378. @@ -1238,6 +1284,7 @@
  379. ,.fragment= ""
  380. ,.request_path= "/"
  381. ,.request_url= "/"
  382. + ,.content_length= -1
  383. ,.num_headers= 1
  384. ,.headers=
  385. { { "Transfer-Encoding" , "deflate, chunked" }
  386. @@ -1275,6 +1322,7 @@
  387. ,.http_minor= 1
  388. ,.status_code= 301
  389. ,.response_status= "Moved Permanently"
  390. + ,.content_length= 219
  391. ,.num_headers= 8
  392. ,.headers=
  393. { { "Location", "http://www.google.com/" }
  394. @@ -1324,6 +1372,7 @@
  395. ,.http_minor= 1
  396. ,.status_code= 200
  397. ,.response_status= "OK"
  398. + ,.content_length= -1
  399. ,.num_headers= 5
  400. ,.headers=
  401. { { "Date", "Tue, 04 Aug 2009 07:59:32 GMT" }
  402. @@ -1353,6 +1402,7 @@
  403. ,.http_minor= 1
  404. ,.status_code= 404
  405. ,.response_status= "Not Found"
  406. + ,.content_length= -1
  407. ,.num_headers= 0
  408. ,.headers= {}
  409. ,.body_size= 0
  410. @@ -1368,6 +1418,7 @@
  411. ,.http_major= 1
  412. ,.http_minor= 1
  413. ,.status_code= 301
  414. + ,.content_length= -1
  415. ,.response_status= ""
  416. ,.num_headers= 0
  417. ,.headers= {}
  418. @@ -1395,6 +1446,7 @@
  419. ,.http_minor= 1
  420. ,.status_code= 200
  421. ,.response_status= "OK"
  422. + ,.content_length= -1
  423. ,.num_headers= 2
  424. ,.headers=
  425. { {"Content-Type", "text/plain" }
  426. @@ -1422,6 +1474,7 @@
  427. ,.http_minor= 1
  428. ,.status_code= 200
  429. ,.response_status= "OK"
  430. + ,.content_length= -1
  431. ,.num_headers= 2
  432. ,.headers=
  433. { {"Content-Type", "text/html; charset=utf-8" }
  434. @@ -1446,6 +1499,7 @@
  435. ,.http_minor= 1
  436. ,.status_code= 200
  437. ,.response_status= "OK"
  438. + ,.content_length= 11
  439. ,.num_headers= 4
  440. ,.headers=
  441. { {"Content-Type", "text/html; charset=UTF-8" }
  442. @@ -1472,6 +1526,7 @@
  443. ,.http_minor= 1
  444. ,.status_code= 200
  445. ,.response_status= "OK"
  446. + ,.content_length= 0
  447. ,.num_headers= 4
  448. ,.headers=
  449. { {"Server", "DCLK-AdSvr" }
  450. @@ -1505,6 +1560,7 @@
  451. ,.http_minor= 0
  452. ,.status_code= 301
  453. ,.response_status= "Moved Permanently"
  454. + ,.content_length= 0
  455. ,.num_headers= 9
  456. ,.headers=
  457. { { "Date", "Thu, 03 Jun 2010 09:56:32 GMT" }
  458. @@ -1544,6 +1600,7 @@
  459. ,.http_minor= 1
  460. ,.status_code= 200
  461. ,.response_status= "OK"
  462. + ,.content_length= -1
  463. ,.num_headers= 11
  464. ,.headers=
  465. { { "Date", "Tue, 28 Sep 2010 01:14:13 GMT" }
  466. @@ -1578,6 +1635,7 @@
  467. ,.http_minor= 1
  468. ,.status_code= 500
  469. ,.response_status= "Oriëntatieprobleem"
  470. + ,.content_length= 0
  471. ,.num_headers= 3
  472. ,.headers=
  473. { { "Date", "Fri, 5 Nov 2010 23:07:12 GMT+2" }
  474. @@ -1599,6 +1657,7 @@
  475. ,.http_minor= 9
  476. ,.status_code= 200
  477. ,.response_status= "OK"
  478. + ,.content_length= -1
  479. ,.num_headers= 0
  480. ,.headers=
  481. {}
  482. @@ -1622,6 +1681,7 @@
  483. ,.http_minor= 1
  484. ,.status_code= 200
  485. ,.response_status= "OK"
  486. + ,.content_length= -1
  487. ,.num_headers= 1
  488. ,.headers=
  489. { { "Content-Type", "text/plain" }
  490. @@ -1641,6 +1701,7 @@
  491. ,.http_minor= 0
  492. ,.status_code= 200
  493. ,.response_status= "OK"
  494. + ,.content_length= -1
  495. ,.num_headers= 1
  496. ,.headers=
  497. { { "Connection", "keep-alive" }
  498. @@ -1661,6 +1722,7 @@
  499. ,.http_minor= 0
  500. ,.status_code= 204
  501. ,.response_status= "No content"
  502. + ,.content_length= -1
  503. ,.num_headers= 1
  504. ,.headers=
  505. { { "Connection", "keep-alive" }
  506. @@ -1680,6 +1742,7 @@
  507. ,.http_minor= 1
  508. ,.status_code= 200
  509. ,.response_status= "OK"
  510. + ,.content_length= -1
  511. ,.num_headers= 0
  512. ,.headers={}
  513. ,.body_size= 0
  514. @@ -1697,6 +1760,7 @@
  515. ,.http_minor= 1
  516. ,.status_code= 204
  517. ,.response_status= "No content"
  518. + ,.content_length= -1
  519. ,.num_headers= 0
  520. ,.headers={}
  521. ,.body_size= 0
  522. @@ -1715,6 +1779,7 @@
  523. ,.http_minor= 1
  524. ,.status_code= 204
  525. ,.response_status= "No content"
  526. + ,.content_length= -1
  527. ,.num_headers= 1
  528. ,.headers=
  529. { { "Connection", "close" }
  530. @@ -1737,6 +1802,7 @@
  531. ,.http_minor= 1
  532. ,.status_code= 200
  533. ,.response_status= "OK"
  534. + ,.content_length= -1
  535. ,.num_headers= 1
  536. ,.headers=
  537. { { "Transfer-Encoding", "chunked" }
  538. @@ -1767,6 +1833,7 @@
  539. ,.http_minor= 1
  540. ,.status_code= 200
  541. ,.response_status= "OK"
  542. + ,.content_length= 16
  543. ,.num_headers= 7
  544. ,.headers=
  545. { { "Server", "Microsoft-IIS/6.0" }
  546. @@ -1805,6 +1872,7 @@
  547. ,.http_minor= 1
  548. ,.status_code= 301
  549. ,.response_status= "MovedPermanently"
  550. + ,.content_length= -1
  551. ,.num_headers= 9
  552. ,.headers= { { "Date", "Wed, 15 May 2013 17:06:33 GMT" }
  553. , { "Server", "Server" }
  554. @@ -1832,6 +1900,7 @@
  555. ,.http_minor= 1
  556. ,.status_code= 200
  557. ,.response_status= ""
  558. + ,.content_length= -1
  559. ,.num_headers= 0
  560. ,.headers= {}
  561. ,.body= ""
  562. @@ -1854,6 +1923,7 @@
  563. ,.http_minor= 1
  564. ,.status_code= 200
  565. ,.response_status= "OK"
  566. + ,.content_length= -1
  567. ,.num_headers= 2
  568. ,.headers= { { "Content-Length-X", "0" }
  569. , { "Transfer-Encoding", "chunked" }
  570. @@ -1878,6 +1948,7 @@
  571. ,.status_code= 101
  572. ,.response_status= "Switching Protocols"
  573. ,.upgrade= "proto"
  574. + ,.content_length= -1
  575. ,.num_headers= 2
  576. ,.headers=
  577. { { "Connection", "upgrade" }
  578. @@ -1903,6 +1974,7 @@
  579. ,.response_status= "Switching Protocols"
  580. ,.body= "body"
  581. ,.upgrade= "proto"
  582. + ,.content_length= 4
  583. ,.num_headers= 3
  584. ,.headers=
  585. { { "Connection", "upgrade" }
  586. @@ -1934,6 +2006,7 @@
  587. ,.response_status= "Switching Protocols"
  588. ,.body= "body"
  589. ,.upgrade= "proto"
  590. + ,.content_length= -1
  591. ,.num_headers= 3
  592. ,.headers=
  593. { { "Connection", "upgrade" }
  594. @@ -1960,6 +2033,7 @@
  595. ,.response_status= "OK"
  596. ,.body= "body"
  597. ,.upgrade= NULL
  598. + ,.content_length= -1
  599. ,.num_headers= 2
  600. ,.headers=
  601. { { "Connection", "upgrade" }
  602. @@ -1982,6 +2056,7 @@
  603. ,.http_minor= 1
  604. ,.status_code= 200
  605. ,.response_status= "OK"
  606. + ,.content_length= 4
  607. ,.num_headers= 3
  608. ,.body= "body"
  609. ,.upgrade= NULL
  610. @@ -2012,6 +2087,7 @@
  611. ,.http_minor= 1
  612. ,.status_code= 200
  613. ,.response_status= "OK"
  614. + ,.content_length= -1
  615. ,.num_headers= 3
  616. ,.body= "body"
  617. ,.upgrade= NULL
  618. @@ -2039,6 +2115,7 @@
  619. ,.http_minor= 1
  620. ,.status_code= 200
  621. ,.response_status= "OK"
  622. + ,.content_length= -1
  623. ,.num_headers= 1
  624. ,.headers= { { "Transfer-Encoding", "chunked, identity" }
  625. }
  626. @@ -2202,6 +2279,7 @@
  627. messages[num_messages].status_code = parser.status_code;
  628. messages[num_messages].http_major = parser.http_major;
  629. messages[num_messages].http_minor = parser.http_minor;
  630. + messages[num_messages].content_length = parser.content_length;
  631. messages[num_messages].headers_complete_cb_called = TRUE;
  632. messages[num_messages].should_keep_alive = http_should_keep_alive(&parser);
  633. return 0;
  634. @@ -2650,6 +2728,7 @@
  635. MESSAGE_CHECK_NUM_EQ(expected, m, http_major);
  636. MESSAGE_CHECK_NUM_EQ(expected, m, http_minor);
  637. + MESSAGE_CHECK_NUM_EQ(expected, m, content_length);
  638. if (expected->type == HTTP_REQUEST) {
  639. MESSAGE_CHECK_NUM_EQ(expected, m, method);
  640. @@ -4351,6 +4430,7 @@
  641. ,.http_minor= 0
  642. ,.status_code= 200
  643. ,.response_status= "OK"
  644. + ,.content_length= -1
  645. ,.num_headers= 2
  646. ,.headers=
  647. { { "Transfer-Encoding", "chunked" }