preflight request fix
This commit is contained in:
1 parent
612615e8ae
commit
09a6585618
4 files changed
+6
-12
No files matched your search
@@ -39,7 +39,6 @@ namespace Http
|
|||||||
m.request = new HttpRequest()
|
m.request = new HttpRequest()
|
||||||
m.header = invalid
|
m.header = invalid
|
||||||
m.response = invalid
|
m.response = invalid
|
||||||
m.header_only = false
|
|
||||||
m.close = true
|
m.close = true
|
||||||
m.ws_upgrade = false
|
m.ws_upgrade = false
|
||||||
m.SetState(Http.HttpConnectionState.INIT)
|
m.SetState(Http.HttpConnectionState.INIT)
|
||||||
@@ -122,17 +121,13 @@ namespace Http
|
|||||||
end if
|
end if
|
||||||
|
|
||||||
if m.response.DoneHeader()
|
if m.response.DoneHeader()
|
||||||
if m.response.header_only
|
m.SetState(Http.HttpConnectionState.SEND_RESPONSE)
|
||||||
m.SetState(Http.HttpConnectionState.DONE)
|
m.PollResponse(server)
|
||||||
else
|
|
||||||
m.SetState(Http.HttpConnectionState.SEND_RESPONSE)
|
|
||||||
m.PollResponse(server)
|
|
||||||
end if
|
|
||||||
end if
|
end if
|
||||||
end function
|
end function
|
||||||
|
|
||||||
function PollResponse(server as HttpServer)
|
function PollResponse(server as HttpServer)
|
||||||
if m.state <> Http.HttpConnectionState.SEND_RESPONSE or m.response.header_only
|
if m.state <> Http.HttpConnectionState.SEND_RESPONSE
|
||||||
LogError("illegal response state @" + m.client)
|
LogError("illegal response state @" + m.client)
|
||||||
end if
|
end if
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ namespace Http
|
|||||||
private body_buffer_length = 0
|
private body_buffer_length = 0
|
||||||
private sent = 0
|
private sent = 0
|
||||||
private header_sent = 0
|
private header_sent = 0
|
||||||
private header_only = false
|
|
||||||
private buf_start = 0
|
private buf_start = 0
|
||||||
private http_code = 0
|
private http_code = 0
|
||||||
|
|
||||||
@@ -125,7 +124,7 @@ ${m.GeneratedBy()}
|
|||||||
buf_pos = m.start + m.sent - m.buf_start
|
buf_pos = m.start + m.sent - m.buf_start
|
||||||
buf_remaining = m.body_buffer.count() - buf_pos
|
buf_remaining = m.body_buffer.count() - buf_pos
|
||||||
if buf_remaining = 0
|
if buf_remaining = 0
|
||||||
' This is expected if there's an ETag cache hit
|
' This is expected if there's an ETag cache hit, or if body is empty
|
||||||
LogDebug("source buffer is empty")
|
LogDebug("source buffer is empty")
|
||||||
end if
|
end if
|
||||||
req_remaining = m.body_buffer_length - m.sent
|
req_remaining = m.body_buffer_length - m.sent
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ namespace Http
|
|||||||
end if
|
end if
|
||||||
|
|
||||||
if request.method = "OPTIONS"
|
if request.method = "OPTIONS"
|
||||||
response.header_only = true
|
response.ClearBody()
|
||||||
response.http_code = 200
|
response.http_code = 200
|
||||||
return true
|
return true
|
||||||
end if
|
end if
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ namespace Http
|
|||||||
response.headers["Connection"] = "Upgrade"
|
response.headers["Connection"] = "Upgrade"
|
||||||
response.headers["Upgrade"] = "websocket"
|
response.headers["Upgrade"] = "websocket"
|
||||||
response.headers["Sec-WebSocket-Accept"] = webSocketAccept
|
response.headers["Sec-WebSocket-Accept"] = webSocketAccept
|
||||||
response.header_only = true
|
response.ClearBody()
|
||||||
|
|
||||||
' We want this connection to be upgraded to a WebSocket connection
|
' We want this connection to be upgraded to a WebSocket connection
|
||||||
' The connection will stop being handled by the HTTP server and will be handled by the WebSocket server
|
' The connection will stop being handled by the HTTP server and will be handled by the WebSocket server
|
||||||
|
|||||||
Reference in new issue
Block a user