Process local http request (#599)
* Local http? * option utils * Fix for hanging web app * Lint fix --------- Co-authored-by: github-action linter <githubaction@githubaction.com>
This commit is contained in:
1 parent
fae875845a
commit
f3f9327c1c
8 files changed
+123
-11
No files matched your search
@@ -34,6 +34,15 @@ namespace Http
|
||||
m.headers = CreateObject("roAssociativeArray")
|
||||
end function
|
||||
|
||||
function FromParsedData(method as string, uri as string, headers as object, body as string)
|
||||
m.method = method
|
||||
m.uri = uri
|
||||
m.ProcessOperation()
|
||||
m.headers = headers
|
||||
m.body = body
|
||||
m.state = Http.HttpRequestState.DONE
|
||||
end function
|
||||
|
||||
function Add(incoming as string, maybeUnicode as boolean)
|
||||
if IsString(m.buffer)
|
||||
m.buffer = m.buffer + incoming
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Http
|
||||
m.routes = []
|
||||
end function
|
||||
|
||||
private function OnRequest(request as object, response as HttpResponse, connection as HttpConnection) as boolean
|
||||
function OnRequest(request as object, response as HttpResponse, connection as HttpConnection) as boolean
|
||||
for each route in m.routes
|
||||
if m.RouteMatchesRequest(route, request)
|
||||
try
|
||||
|
||||
@@ -195,6 +195,22 @@ namespace Http
|
||||
stats = stats + " Bytes" + Stri(m.total_in) + " in," + Stri(m.total_out) + " out"
|
||||
return stats
|
||||
end function
|
||||
|
||||
function ProcessRequestLocal(method as string, uri as string, headers as object, body as string) as object
|
||||
LogInfo(`Processing request locally ${method} ${uri}`)
|
||||
request = new HttpRequest()
|
||||
request.FromParsedData(method, uri, headers, body)
|
||||
|
||||
response = new HttpResponse(request, m, m.settings)
|
||||
response.Process({})
|
||||
|
||||
return {
|
||||
http_code: response.http_code
|
||||
headers: response.headers
|
||||
body: response.body_buffer
|
||||
}
|
||||
end function
|
||||
|
||||
end class
|
||||
|
||||
end namespace
|
||||
Reference in new issue
Block a user