browserify / browserify/http-browserify

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

オープン
#81 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
JavaScript
スター
245
フォーク
104
PR マージ指標
30日以内にマージされた PR はありません

説明

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)

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

http-browserify の Response の定義とその util.inherits 呼び出しから始め、issue に示されている Node の IncomingMessage の継承と比較してください。request.js の回避策を確認し、Response を Streams2 に変換するために継承以外の変更が必要かどうかを判断してください。ブラウザーのレスポンスが resume() を含む期待される Readable API を、この互換性回避策なしで公開すれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript, node.js
領域
web-dev
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
38/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。