HEAD request not working on Edge
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 42/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript
- Domain
- api
Research direction
Start at IncomingMessage, where the fetch response body is read with getReader(), and reproduce a HEAD request in Edge. Handle the null response body without crashing or hanging, while preserving the existing behavior for responses with bodies.
Written by the indexing model from the issue text.
Description
When doing a HEAD request with the http library, the javascript just crashes and does not give me any answers.
I tried debugging it myself and found that the library uses fetch to fetch the head. The response of this message is given to IncomingMessage. IncomingMessage assumes that a response has a body. In the case of Edge, the body is just null, because a HEAD request has no body.
Nonetheless, this is accessed in anyway:
var reader = response.body.getReader()
function read () {
reader.read().then(function (result) {
if (self._destroyed)
return
if (result.done) {
self.push(null)
return
}
self.push(new Buffer(result.value))
read()
}).catch(function(err) {
self.emit('error', err)
})
}
And libraries crashes, causing the HEAD request to hang indefinitely.
To be able to use my own code I added a monkey fix, to temporarily make edge work:
window.fetch_old = window.fetch
window.fetch = function () {
var result = window.fetch_old.apply(null, arguments);
result.then_old = result.then;
result.then = function (callback) {
return result.then_old(function(response) {
if(response.body === null){
var body = { "getReader" : function () {
return {
"read" : function (){
return {
"then" : function (callback){
callback({"done":true});
return {"catch" : function(){}};
}
}
}
}
}};
//override body....
var handler = {
get: function(target, name) {
if(name === "body"){
return body;
}
return target[name];
}
};
var response_new = new Proxy(response, handler);
return callback(response_new);
}
return callback(response);
});
}
return result;
};
But obviously, it would be great if this could be fixed in the library, instead of my ugly hack.
- Dominant language
- JavaScript
- Stars
- 245
- Forks
- 104
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from browserify/http-browserify
-
Difficulty 2/5 1-3 hours Newbie friendliness 52/100
browserify/http-browserify#107 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 48/100
browserify/http-browserify#102 ·
-
Needs Maintainer Open
Difficulty 5/5 Over a week Newbie friendliness 15/100
browserify/http-browserify#99 · 2 reactions ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 38/100
browserify/http-browserify#96 · 2 comments · 1 reaction ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
All issues in browserify/http-browserify
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
palladius/rails8-app-on-gcp#145 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
dotenvx/dotenv-vscode#139 ·
-
test-change-proposal
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
web-platform-tests/interop#1455 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
corsairdev/corsair#1764 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100