You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just to document here for others. I am using the following code for local files. It works "good enough", but probably one could do smarter things with settings _require and _response to some random values, just to be sure.
fs=require'fs'URL_BASE='/srv/files/'classLocalFilesXMLHttpRequestextendsXMLHttpRequest_sendRelative: (data) ->fullUrl=url.resolve URL_BASE, @_url.href@_url=@_parseUrl fullUrl
@_sendFile data
_sendFile: (data) ->unless@_methodis'GET'thrownewNetworkError"The file protocol only supports GET"if data?and (@_methodis'GET'or@_methodis'HEAD')
console.warn"Discarding entity body for #{@_method} requests"data=nullelse# Send Content-Length: 0dataor=''@upload._setData data
@_finalizeHeaders()
@_request=null@_dispatchProgress'loadstart'if@_syncdefer= (f) ->f()
elsedefer=process.nextTickdefer=>trydata=fs.readFileSync@_url.pathnamecatch error
# TODO: Should set status based on the errordata=newBuffer"#{ error }"status=404@_response=null@status= status
@statusText=http.STATUS_CODES[@status]
@_totalBytes=data.length@_lengthComputable=true@_setReadyStateXMLHttpRequest.HEADERS_RECEIVED@_onHttpResponseDatanull, data
@_onHttpResponseEndnull
The text was updated successfully, but these errors were encountered:
Just to document here for others. I am using the following code for local files. It works "good enough", but probably one could do smarter things with settings
_require
and_response
to some random values, just to be sure.The text was updated successfully, but these errors were encountered: