browserify / browserify/http-browserify

Response inherits from Stream instead of Stream.Readable (requiring request module browserify workaround)

Abierto
#81 4 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
JavaScript
Estrellas
245
Forks
104
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

On node.js, the HTTP response object (which is named IncomingMessage in node.js) [inherits from Stream.Readable](https://github.com/request/request/commit/6ebd748a02a49976d41ebbc4f8396acf8fda1c14):

``` javascript
util.inherits(IncomingMessage, Stream.Readable);
```

but in http-browserify, it [only inherits from Stream](https://github.com/joyent/node/blob/1781c8b85bbabc4c5c1e054bd5c50903cc0eb47b/lib/_http_incoming.js#L80):

``` javascript
util.inherits(Response, Stream);
```

This means the full stream API is not available as it is in Node, including the [.resume](http://nodejs.org/api/stream.html#stream_readable_resume)() method. I believe this is the reason for [this ](https://github.com/request/request/commit/6ebd748a02a49976d41ebbc4f8396acf8fda1c14) [hack](https://github.com/request/request/blob/a60482bf06b7e16d3cdbabcdee7f0b62d93117c2/request.js#L973-975) in the [request](http://github.com/request/request) module:

``` javascript
} else if (response.resume) {
// response.resume should be defined, but check anyway before calling.
// Workaround for browserify.
response.resume()
}
```

to improve compatibility would it be possible for http-browserify Response to inherit from Stream.Readable? (are there any other changes needed than changing the utils.inherits call?)

edit: Stream is old-style (pre-0.10); this amounts to converting http-browserify to [Streams2](https://rawgit.com/rvagg/rvagg.github.com/master/2014/06/why-i-dont-use-nodes-core-stream-module.html)

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Línea de trabajo

Comienza por la definición de Response en http-browserify y su llamada a util.inherits; después, compárala con la herencia de IncomingMessage de Node que se muestra en el issue. Comprueba la solución alternativa de request.js y determina si convertir Response a Streams2 requiere cambios más allá de la herencia. La tarea estará terminada cuando la respuesta del navegador exponga la API Readable esperada, incluido resume(), sin esa solución alternativa de compatibilidad.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
javascript, node.js
Área
web-dev
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
38/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.