This repository was archived by the owner on Dec 27, 2022. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ /**
2+ * HACK
3+ * Electron has an issue that's causing file read streams to fail to serve
4+ * Reading into memory seems to resolve the issue
5+ * https://github.com/electron/electron/issues/21018
6+ * -prf
7+ */
8+ import { PassThrough } from 'stream'
9+ function intoStream ( text ) {
10+ const rv = new PassThrough ( )
11+ rv . push ( text )
12+ rv . push ( null )
13+ return rv
14+ }
15+
16+ // exported api
17+ // =
18+
19+ export function register ( protocol ) {
20+ protocol . registerStreamProtocol ( 'dat' , electronHandler )
21+ }
22+
23+ export const electronHandler = async function ( request , respond ) {
24+ respond ( {
25+ statusCode : 200 ,
26+ headers : {
27+ Location : request . replace ( 'dat:' , 'hd:' )
28+ } ,
29+ data : intoStream ( `Redirecting...` )
30+ } )
31+ }
You can’t perform that action at this time.
0 commit comments