mirror of
https://github.com/syumai/workers.git
synced 2025-03-10 17:29:11 +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("statusText", http.StatusText(status))
|
||||
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)
|
||||
return jsutil.ResponseClass.New(readableStream, respInit), nil
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ var (
|
||||
ErrorClass = Global.Get("Error")
|
||||
ReadableStreamClass = Global.Get("ReadableStream")
|
||||
DateClass = Global.Get("Date")
|
||||
Null = js.ValueOf(nil)
|
||||
)
|
||||
|
||||
func NewObject() js.Value {
|
||||
|
Loading…
x
Reference in New Issue
Block a user