Skip to content

Commit

Permalink
added warn on failed check, removed a redundant check
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperMaxusa authored Nov 12, 2024
1 parent 160d577 commit d3998fc
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/browser/fetch_network.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ async function on_data_http(data)
for(let i = 1; i < headers.length; ++i) {
const header = this.net.parse_http_header(headers[i]);
if(!header) {
console.warn('The request contains an invalid header: "%s"', header);
this.write(new TextEncoder().encode("HTTP/1.1 400 Bad Request\r\nContent-Length: 0"));
return;
}
Expand Down Expand Up @@ -155,12 +156,6 @@ FetchNetworkAdapter.prototype.fetch = async function(url, options)

FetchNetworkAdapter.prototype.parse_http_header = function(header)
{
if(!header.includes(":"))
{
dbg_log("Header doesn't have a separator", LOG_FETCH);
return;
}

const parts = header.match(/^([^:]*):(.*)$/);
if(parts === null || parts.length !== 3) {
dbg_log("Unable to parse HTTP header", LOG_FETCH);
Expand All @@ -172,7 +167,7 @@ FetchNetworkAdapter.prototype.parse_http_header = function(header)

if(key.length === 0)
{
dbg_log("Header key is empty", LOG_FETCH);
dbg_log("Header key is empty, raw header", LOG_FETCH);
return;
}
if(value.length === 0)
Expand Down

0 comments on commit d3998fc

Please sign in to comment.