•  


Streaming support · Issue #198 · JakeChampion/fetch · GitHub
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Streaming support #198

Closed
atgillette opened this issue Aug 24, 2015 · 13 comments
Closed

Streaming support #198

atgillette opened this issue Aug 24, 2015 · 13 comments

Comments

@atgillette
Copy link

Is there any plans to add support for streaming, something like what request has?

@dgraham
Copy link
Contributor

There are no current plans for streaming requests or responses. We are limited by what XMLHttpRequest supports.

There is a draft specification for streams in the Fetch API, with a native implementation shipping in Chrome already.

@jimmywarting
Copy link

jimmywarting commented Sep 16, 2016

Please reopen, there are two was you can get a stream from XMLHttpRequest.

xhrRequest
.
responseType
 =
 "ms-stream"
;

// or

xhrRequest
.
responseType
 =
 "moz-chunked-arraybuffer"
;

If this would be implemented then i would rather want to use the polyfill then firefox or edge partially supported fetch api
This is crucial for my application where i need to handle large file with lower memory.
And with web-stream-polyfill this would be a breeze

@mislav
Copy link
Contributor

Sure, let's revisit this. But I make no promises about actually implementing this in github/fetch.

It sounds like we can get native streaming from Chrome 43+, and streaming via XHR in IE and Firefox. How about Safari? is anything available there?

@mislav mislav reopened this Sep 17, 2016
@jimmywarting
Copy link

Like i said to jonnyreeves/chunked-request

Played a bit myself with streams and monkey patching xhr:
This is how i would do it for firefox: https://jsfiddle.net/98L105v3/2/

I created it yesterday, maybe it would be of any interest?

@jimmywarting
Copy link

jimmywarting commented Sep 17, 2016

Borrow some info from jonnyreeves/chunked-request#16

  • Chrome: use native reader from fetch
  • FF: set responseType to moz-chunked-arraybuffer, get ArrayBuffer(s) from xhr.response progress event(s), accumulate if needed, resolve reader.read Promise
  • IE10+: set responseType to ms-stream, call readAsArrayBuffer on xhr.response to get an eventemitter, get ArrayBuffer(s) from eventemitter progress event(s), accumulate if needed, resolve reader.read Promise
  • IE9: set responseType to text, slice xhr.responseText on progress event(s) to get chunk(s), convert to ArrayBuffer(s) using text-encoding-utf-8, accumulate if needed, resolve reader.read Promise
  • Safari: until it supports fetch, basically do the same thing as for IE9, except use native Uint8Array when converting to ArrayBuffer like this.

They also utility a partial request method (making multiple range request) Perhaps this would be a solution or just make it overkill

@jimmywarting
Copy link

jimmywarting commented Sep 17, 2016

if this gets implemented the we can't use this code any longer

  if
 (
self
.
fetch
)
 {

    return

  }

Cuz with streams i think the polyfill would actually be better then the partial fetch api FF & Edge supports

@jimmywarting
Copy link

Oh, and by the way.
If someone would do new Responsen(blob, {}).body.getReader() then there is some code you can take out of my Screw-FileReader lib about the part where I make a blob to a ReadableStream ??

@caub
Copy link

caub commented Oct 28, 2016

Even if XMLHttpRequest can't really do streams, I think it would be great to have https://github.com/domenic/streams-demo working on old browsers, with only one chunk, and by adding a res.body.getReader()

@happycollision
Copy link

@jimmywarting I'm not sure if this is still a concern, but the workaround method for a bad FileReader might also work to allow this polyfill to override a native implementation so you can keep your preferred streaming when browsers only offer partial support.

@mutantcornholio
Copy link

this project probably deserves to be looked at too

@Angel3477

This comment has been minimized.

@sandorvasas
Copy link

still no stream support?

@mislav
Copy link
Contributor

Still no streaming support, and I think that it's safe to decide at this point that this polyfill will never have streaming support.

This polyfill has been feature-complete for a while (i.e. has all the features implemented that cover most common usages of fetch ) and will likely get no new large features. Furthermore, this polyfill isn't even used in any of today's modern browsers, since Chrome, Firefox, Safari, and Edge all have shipped with a native implementation of window.fetch for a long while now.

If your app really needs streaming, feature-detect it and use native browser capabilities. When streaming capabilities are not present (e.g. when this polyfill is being used in old browsers), your app should gracefully fall back to regular request/response reading.

Sign up for free to subscribe to this conversation on GitHub . Already have an account? Sign in .
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants
- "漢字路" 한글한자자동변환 서비스는 교육부 고전문헌국역지원사업의 지원으로 구축되었습니다.
- "漢字路" 한글한자자동변환 서비스는 전통문화연구회 "울산대학교한국어처리연구실 옥철영(IT융합전공)교수팀"에서 개발한 한글한자자동변환기를 바탕하여 지속적으로 공동 연구 개발하고 있는 서비스입니다.
- 현재 고유명사(인명, 지명등)을 비롯한 여러 변환오류가 있으며 이를 해결하고자 많은 연구 개발을 진행하고자 하고 있습니다. 이를 인지하시고 다른 곳에서 인용시 한자 변환 결과를 한번 더 검토하시고 사용해 주시기 바랍니다.
- 변환오류 및 건의,문의사항은 juntong@juntong.or.kr로 메일로 보내주시면 감사하겠습니다. .
Copyright ⓒ 2020 By '전통문화연구회(傳統文化硏究會)' All Rights reserved.
 한국   대만   중국   일본