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
@@ -9,6 +9,7 @@ namespace Http
|
||||
function new(server as object)
|
||||
super()
|
||||
|
||||
m.server = server
|
||||
task = server.task
|
||||
m.profilesNode = task.profilesService
|
||||
m.invidiousNode = task.invidious
|
||||
@@ -72,12 +73,15 @@ namespace Http
|
||||
return true
|
||||
end if
|
||||
|
||||
additionalQueryParams = invalid
|
||||
options = {
|
||||
httpServer: m.server
|
||||
}
|
||||
if feedSource.state <> invalid and feedSource.state.queryParams <> invalid
|
||||
additionalQueryParams = feedSource.state.queryParams
|
||||
options.additionalQueryParams = feedSource.state.queryParams
|
||||
end if
|
||||
|
||||
invResponse = m.invidiousService.MakeRequest(feedSource, additionalQueryParams)
|
||||
invResponse = m.invidiousService.MakeRequest(feedSource, options)
|
||||
|
||||
if not invResponse.success
|
||||
response.Default(500, `Failed to make request: ${invResponse.error}`)
|
||||
return true
|
||||
|
||||
@@ -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