diff options
Diffstat (limited to 'src/io')
-rw-r--r-- | src/io/loader.nim | 1 | ||||
-rw-r--r-- | src/io/request.nim | 12 | ||||
-rw-r--r-- | src/io/response.nim | 1 |
3 files changed, 6 insertions, 8 deletions
diff --git a/src/io/loader.nim b/src/io/loader.nim index e88a4a69..6583ce2c 100644 --- a/src/io/loader.nim +++ b/src/io/loader.nim @@ -32,7 +32,6 @@ import io/urlfilter import ips/serialize import ips/serversocket import ips/socketstream -import js/exception import js/javascript import types/cookie import types/mime diff --git a/src/io/request.nim b/src/io/request.nim index a5a0158f..af7daf47 100644 --- a/src/io/request.nim +++ b/src/io/request.nim @@ -5,7 +5,6 @@ import tables import bindings/quickjs import io/headers -import js/exception import js/javascript import types/formdata import types/url @@ -200,7 +199,7 @@ func newRequest*(ctx: JSContext, resource: string, var credentials = CredentialsMode.SAME_ORIGIN var mode = fallbackMode.get(RequestMode.NO_CORS) let hl = newHeaders() - var proxyUrl: Opt[URL] + var proxyUrl: URL var multipart: Opt[FormData] #TODO fallback mode, origin, window, request mode, ... if init.isSome: @@ -210,9 +209,9 @@ func newRequest*(ctx: JSContext, resource: string, let bodyProp = JS_GetPropertyStr(ctx, init, "body") if not JS_IsNull(bodyProp) and not JS_IsUndefined(bodyProp): # ???? - multipart = fromJS[FormData](ctx, bodyProp) + multipart = opt(fromJS[FormData](ctx, bodyProp)) if multipart.isNone: - body = fromJS[string](ctx, bodyProp) + body = opt(fromJS[string](ctx, bodyProp)) #TODO inputbody if (multipart.isSome or body.isSome) and httpMethod in {HTTP_GET, HTTP_HEAD}: @@ -224,9 +223,10 @@ func newRequest*(ctx: JSContext, resource: string, mode = fromJS[RequestMode](ctx, JS_GetPropertyStr(ctx, init, "mode")) .get(mode) #TODO find a standard compatible way to implement this - proxyUrl = fromJS[URL](ctx, JS_GetPropertyStr(ctx, init, "proxyUrl")) + let proxyUrlProp = JS_GetPropertyStr(ctx, init, "proxyUrl") + proxyUrl = fromJS[URL](ctx, proxyUrlProp).get(nil) return ok(newRequest(url, httpMethod, hl, body, multipart, mode, credentials, - proxy = proxyUrl.get(nil))) + proxy = proxyUrl)) func credentialsMode*(attribute: CORSAttribute): CredentialsMode = case attribute diff --git a/src/io/response.nim b/src/io/response.nim index 321f43d0..6a5a5bbf 100644 --- a/src/io/response.nim +++ b/src/io/response.nim @@ -4,7 +4,6 @@ import bindings/quickjs import io/headers import io/promise import io/request -import js/exception import js/javascript import types/url |