I got an har file exported by Chrome DevTools. It shows an incomplete http response with error net::ERR_INCOMPLETE_CHUNKED_ENCODING
. the incomplete http response has been transfered 4096 bytes.
"content": {
"size": 67469,
"mimeType": "application/octet-stream",
"compression": 63629
},
"redirectURL": "",
"headersSize": 256,
"bodySize": 3840,
"_transferSize": 4096,
"_error": "net::ERR_INCOMPLETE_CHUNKED_ENCODING"
},
My questing is how does Chrome DevTools know that the http response's content size 67469 bytes as the responese is INCOMPLETE?
Here is the whole request record by Chrome DevTools(Sensitive infos is replaced):
{
"_initiator": {
"type": "script",
"stack": {
"callFrames": [1, 2, 3, 4],
"parentId": {
"id": "4",
"debuggerId": "xxx.-xxx"
}
}
},
"_priority": "High",
"_resourceType": "fetch",
"cache": {},
"connection": "24665",
"request": {
"method": "GET",
"url": "http://www.example.com?hello=world",
"httpVersion": "HTTP/1.1",
"headers": [
{
"name": "Accept",
"value": "*/*"
},
{
"name": "Accept-Encoding",
"value": "gzip, deflate"
},
{
"name": "Accept-Language",
"value": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6"
},
{
"name": "Cache-Control",
"value": "no-cache"
},
{
"name": "Connection",
"value": "keep-alive"
},
{
"name": "Cookie",
"value": "..."
},
{
"name": "Host",
"value": "www.example.com"
},
{
"name": "Pragma",
"value": "no-cache"
},
{
"name": "Referer",
"value": "http://www.example.com/ref?hello=world"
},
{
"name": "User-Agent",
"value": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36 Edg/110.0.1587.50"
}
],
"queryString": [
{
"name": "hello",
"value": "world"
}
],
"cookies": [1, 2, 3, 4],
"headersSize": 2273,
"bodySize": 0
},
"response": {
"status": 200,
"statusText": "OK",
"httpVersion": "HTTP/1.1",
"headers": [
{
"name": "Cache-Control",
"value": "private"
},
{
"name": "Content-Disposition",
"value": "attachment;FileName=example.pdf"
},
{
"name": "Content-Type",
"value": "application/octet-stream"
},
{
"name": "Date",
"value": "Wed, 22 Feb 2023 17:10:05 GMT"
},
{
"name": "Server",
"value": "Microsoft-IIS/8.0"
},
{
"name": "Transfer-Encoding",
"value": "chunked"
}
],
"cookies": [],
"content": {
"size": 67469,
"mimeType": "application/octet-stream",
"compression": 63629
},
"redirectURL": "",
"headersSize": 256,
"bodySize": 3840,
"_transferSize": 4096,
"_error": "net::ERR_INCOMPLETE_CHUNKED_ENCODING"
},
"serverIPAddress": "1.1.1.1",
"startedDateTime": "2023-02-22T17:10:08.836Z",
"time": 130.23999985307455,
"timings": {
"blocked": 9.5169998755157,
"dns": -1,
"ssl": -1,
"connect": -1,
"send": 0.556,
"wait": 66.90000020015239,
"receive": 53.266999777406454,
"_blocked_queueing": 3.2859998755156994,
"_blocked_proxy": 0.8559999999999999
}
},
The incomplete http above is produced by other people. An I try to reproduce it but failed. I make up a incomplete http response which has the first chunk(chunk-size CRLF chunk-data CRLF) and no last-chunk('0' CRLFCRLF). Chrome DevTools show:
"content": {
"size": 0,
"mimeType": "application/octet-stream",
"compression": 0
},
"redirectURL": "",
"headersSize": 280,
"bodySize": 0,
"_transferSize": 280,
"_error": "net::ERR_INCOMPLETE_CHUNKED_ENCODING"
My questing is how to reproduce the incomplete http response scenario which Chrome DevTools knows the content size?
{
"_initiator": {
"type": "script",
"stack": {
"callFrames": [1, 2, 3, 4, 5],
"parentId": {
"id": "4",
"debuggerId": "-xxxx.-xxxx"
}
}
},
"_priority": "High",
"_resourceType": "fetch",
"cache": {},
"connection": "75735",
"pageref": "page_1",
"request": {
"method": "GET",
"url": "http://localhost:8085/HelloAshx.ashx",
"httpVersion": "HTTP/1.1",
"headers": [
{
"name": "Accept",
"value": "*/*"
},
{
"name": "Accept-Encoding",
"value": "gzip, deflate, br"
},
{
"name": "Accept-Language",
"value": "zh-CN,zh;q=0.9,en;q=0.8"
},
{
"name": "Cache-Control",
"value": "no-cache"
},
{
"name": "Connection",
"value": "keep-alive"
},
{
"name": "Host",
"value": "localhost:8085"
},
{
"name": "Pragma",
"value": "no-cache"
},
{
"name": "Referer",
"value": "http://localhost:8085/Home/About"
},
{
"name": "Sec-Fetch-Dest",
"value": "empty"
},
{
"name": "Sec-Fetch-Mode",
"value": "cors"
},
{
"name": "Sec-Fetch-Site",
"value": "same-origin"
},
{
"name": "User-Agent",
"value": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36"
},
{
"name": "sec-ch-ua",
"value": "\"Chromium\";v=\"110\", \"Not A(Brand\";v=\"24\", \"Google Chrome\";v=\"110\""
},
{
"name": "sec-ch-ua-mobile",
"value": "?0"
},
{
"name": "sec-ch-ua-platform",
"value": "\"Windows\""
}
],
"queryString": [],
"cookies": [1, 2, 3, 4, 5],
"headersSize": 923,
"bodySize": 0
},
"response": {
"status": 200,
"statusText": "OK",
"httpVersion": "HTTP/1.1",
"headers": [
{
"name": "Cache-Control",
"value": "private"
},
{
"name": "Content-Disposition",
"value": "attachment;FileName=example.pdf"
},
{
"name": "Content-Type",
"value": "application/octet-stream"
},
{
"name": "Date",
"value": "Wed, 01 Mar 2023 13:52:37 GMT"
},
{
"name": "Server",
"value": "Microsoft-IIS/10.0"
},
{
"name": "Transfer-Encoding",
"value": "chunked"
},
{
"name": "X-AspNet-Version",
"value": "4.0.30319"
},
{
"name": "X-Powered-By",
"value": "ASP.NET"
}
],
"cookies": [],
"content": {
"size": 0,
"mimeType": "application/octet-stream",
"compression": 0
},
"redirectURL": "",
"headersSize": 280,
"bodySize": 0,
"_transferSize": 280,
"_error": "net::ERR_INCOMPLETE_CHUNKED_ENCODING"
},
"serverIPAddress": "[::1]",
"startedDateTime": "2023-03-01T13:52:37.583Z",
"time": 3.81499994546175,
"timings": {
"blocked": 0.6999999288022518,
"dns": -1,
"ssl": -1,
"connect": -1,
"send": 0.137,
"wait": 1.2820000245794654,
"receive": 1.6959999920800328,
"_blocked_queueing": 0.3269999288022518
}
}