HEAD request not working on Edge
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 42/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- javascript
- Ambito
- api
Direzione di ricerca
Inizia da IncomingMessage, dove il corpo della risposta fetch viene letto con getReader(), e riproduci una richiesta HEAD in Edge. Gestisci il corpo della risposta null senza causare arresti anomali o blocchi, preservando il comportamento esistente per le risposte con corpo.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- JavaScript
- Stelle
- 245
- Fork
- 104
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di browserify/http-browserify
-
Upgrade `Base64` dependency Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 52/100
browserify/http-browserify#107 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 48/100
browserify/http-browserify#102 ·
-
Needs Maintainer Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 15/100
browserify/http-browserify#99 · 2 reazioni ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 38/100
browserify/http-browserify#96 · 2 commenti · 1 reazione ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 45/100
Tutte le issue di browserify/http-browserify
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
Theme loads third-party resources on every page (jsdelivr web font, cdnjs Font Awesome) – GDPR Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
docToolchain/docToolchain#1705 ·
-
Timezone select lists one option per character; duplicate "Failed" reason; shared tracker popover id Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
nightscout/nocturne#1414 ·
-
bug v2
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
modelcontextprotocol/inspector#2458 · 1 commento ·
-
Mend: dependency security vulnerability status: needs triage 🕵️♀️
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
carbon-design-system/ibm-products#9907 ·