mirror of
https://github.com/syumai/workers.git
synced 2025-03-11 09:49:12 +00:00
R: allow null body
This commit is contained in:
parent
086a224243
commit
a19471694e
@ -43,6 +43,12 @@ func ToJSResponse(w *ResponseWriterBuffer) (js.Value, error) {
|
|||||||
respInit.Set("status", status)
|
respInit.Set("status", status)
|
||||||
respInit.Set("statusText", http.StatusText(status))
|
respInit.Set("statusText", http.StatusText(status))
|
||||||
respInit.Set("headers", ToJSHeader(w.Header()))
|
respInit.Set("headers", ToJSHeader(w.Header()))
|
||||||
|
if status == http.StatusSwitchingProtocols ||
|
||||||
|
status == http.StatusNoContent ||
|
||||||
|
status == http.StatusResetContent ||
|
||||||
|
status == http.StatusNotModified {
|
||||||
|
return jsutil.ResponseClass.New(jsutil.Null, respInit), nil
|
||||||
|
}
|
||||||
readableStream := jsutil.ConvertReaderToReadableStream(w.Reader)
|
readableStream := jsutil.ConvertReaderToReadableStream(w.Reader)
|
||||||
return jsutil.ResponseClass.New(readableStream, respInit), nil
|
return jsutil.ResponseClass.New(readableStream, respInit), nil
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ var (
|
|||||||
ErrorClass = Global.Get("Error")
|
ErrorClass = Global.Get("Error")
|
||||||
ReadableStreamClass = Global.Get("ReadableStream")
|
ReadableStreamClass = Global.Get("ReadableStream")
|
||||||
DateClass = Global.Get("Date")
|
DateClass = Global.Get("Date")
|
||||||
|
Null = js.ValueOf(nil)
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewObject() js.Value {
|
func NewObject() js.Value {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user