about summary refs log tree commit diff stats
path: root/src/loader
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-12-28 21:19:21 +0100
committerbptato <nincsnevem662@gmail.com>2023-12-28 21:23:26 +0100
commitd91d1dda2ad1219b3b798eafc14151811ed9a1b3 (patch)
treef82d8da0763f0dbc62dedb2aa9aaa51114d2aad9 /src/loader
parentb035e53d641d71fab89f92cd8d5188501be0d058 (diff)
downloadchawan-d91d1dda2ad1219b3b798eafc14151811ed9a1b3.tar.gz
Compile with styleCheck:usages
much better
Diffstat (limited to 'src/loader')
-rw-r--r--src/loader/cgi.nim4
-rw-r--r--src/loader/loader.nim16
-rw-r--r--src/loader/request.nim14
3 files changed, 17 insertions, 17 deletions
diff --git a/src/loader/cgi.nim b/src/loader/cgi.nim
index 467e2087..4b61399e 100644
--- a/src/loader/cgi.nim
+++ b/src/loader/cgi.nim
@@ -37,7 +37,7 @@ proc setupEnv(cmd, scriptName, pathInfo, requestURI: string, request: Request,
   putEnv("SCRIPT_NAME", scriptName)
   putEnv("SCRIPT_FILENAME", cmd)
   putEnv("REQUEST_URI", requestURI)
-  putEnv("REQUEST_METHOD", $request.httpmethod)
+  putEnv("REQUEST_METHOD", $request.httpMethod)
   var headers = ""
   for k, v in request.headers:
     headers &= k & ": " & v & "\r\n"
@@ -48,7 +48,7 @@ proc setupEnv(cmd, scriptName, pathInfo, requestURI: string, request: Request,
     putEnv("PATH_INFO", pathInfo)
   if url.query.isSome:
     putEnv("QUERY_STRING", url.query.get)
-  if request.httpmethod == HTTP_POST:
+  if request.httpMethod == HTTP_POST:
     if request.multipart.isSome:
       putEnv("CONTENT_TYPE", request.multipart.get.getContentType())
     else:
diff --git a/src/loader/loader.nim b/src/loader/loader.nim
index 44d6034b..72f30cbd 100644
--- a/src/loader/loader.nim
+++ b/src/loader/loader.nim
@@ -146,7 +146,7 @@ proc loadResource(ctx: LoaderContext, request: Request, handle: LoaderHandle) =
         ctx.handleMap[fd] = handle
     else:
       prevurl = request.url
-      case ctx.config.urimethodmap.findAndRewrite(request.url)
+      case ctx.config.uriMethodMap.findAndRewrite(request.url)
       of URI_RESULT_SUCCESS:
         inc tries
         redo = true
@@ -168,7 +168,7 @@ proc onLoad(ctx: LoaderContext, stream: SocketStream) =
     stream.close()
   else:
     let handle = newLoaderHandle(stream, request.canredir)
-    for k, v in ctx.config.defaultHeaders.table:
+    for k, v in ctx.config.defaultheaders.table:
       if k notin request.headers.table:
         request.headers.table[k] = v
     if ctx.config.cookiejar != nil and ctx.config.cookiejar.cookies.len > 0:
@@ -272,7 +272,7 @@ proc initLoaderContext(fd: cint, config: LoaderConfig): LoaderContext =
 
 proc runFileLoader*(fd: cint, config: LoaderConfig) =
   var ctx = initLoaderContext(fd, config)
-  var buffer {.noInit.}: array[16384, uint8]
+  var buffer {.noinit.}: array[16384, uint8]
   while ctx.alive:
     let events = ctx.selector.select(-1)
     var unreg: seq[int]
@@ -344,17 +344,17 @@ proc applyHeaders(loader: FileLoader, request: Request, response: Response) =
   if "Location" in response.headers.table:
     if response.status in 301u16..303u16 or response.status in 307u16..308u16:
       let location = response.headers.table["Location"][0]
-      let url = parseUrl(location, option(request.url))
+      let url = parseURL(location, option(request.url))
       if url.isSome:
         if (response.status == 303 and
-            request.httpmethod notin {HTTP_GET, HTTP_HEAD}) or
+            request.httpMethod notin {HTTP_GET, HTTP_HEAD}) or
             (response.status == 301 or response.status == 302 and
-            request.httpmethod == HTTP_POST):
+            request.httpMethod == HTTP_POST):
           response.redirect = newRequest(url.get, HTTP_GET,
             mode = request.mode, credentialsMode = request.credentialsMode,
             destination = request.destination)
         else:
-          response.redirect = newRequest(url.get, request.httpmethod,
+          response.redirect = newRequest(url.get, request.httpMethod,
             body = request.body, multipart = request.multipart,
             mode = request.mode, credentialsMode = request.credentialsMode,
             destination = request.destination)
@@ -490,7 +490,7 @@ proc onError*(loader: FileLoader, fd: int) =
   loader.ongoing.withValue(fd, buffer):
     let response = buffer[].response
     when defined(debug):
-      var lbuf {.noInit.}: array[BufferSize, char]
+      var lbuf {.noinit.}: array[BufferSize, char]
       if not response.body.atEnd():
         let n = response.body.readData(addr lbuf[0], lbuf.len)
         assert n == 0
diff --git a/src/loader/request.nim b/src/loader/request.nim
index aea5bd46..521362bc 100644
--- a/src/loader/request.nim
+++ b/src/loader/request.nim
@@ -69,8 +69,8 @@ type
 type
   Request* = ref RequestObj
   RequestObj* = object
-    httpmethod*: HttpMethod
-    url*: Url
+    httpMethod*: HttpMethod
+    url*: URL
     headers* {.jsget.}: Headers
     body*: Opt[string]
     multipart*: Opt[FormData]
@@ -158,14 +158,14 @@ proc newReadableStream*(isource: Stream): ReadableStream =
   if len != 0:
     isource.readStr(len, result.buf)
 
-func newRequest*(url: URL, httpmethod = HTTP_GET, headers = newHeaders(),
+func newRequest*(url: URL, httpMethod = HTTP_GET, headers = newHeaders(),
     body = opt(string), multipart = opt(FormData), mode = RequestMode.NO_CORS,
     credentialsMode = CredentialsMode.SAME_ORIGIN,
     destination = RequestDestination.NO_DESTINATION, proxy: URL = nil,
     referrer: URL = nil, canredir = false): Request =
   return Request(
     url: url,
-    httpmethod: httpmethod,
+    httpMethod: httpMethod,
     headers: headers,
     body: body,
     multipart: multipart,
@@ -176,7 +176,7 @@ func newRequest*(url: URL, httpmethod = HTTP_GET, headers = newHeaders(),
     proxy: proxy
   )
 
-func newRequest*(url: URL, httpmethod = HTTP_GET,
+func newRequest*(url: URL, httpMethod = HTTP_GET,
     headers: seq[(string, string)] = @[], body = opt(string),
     multipart = opt(FormData), mode = RequestMode.NO_CORS, proxy: URL = nil,
     canredir = false):
@@ -185,7 +185,7 @@ func newRequest*(url: URL, httpmethod = HTTP_GET,
   for pair in headers:
     let (k, v) = pair
     hl.table[k] = @[v]
-  return newRequest(url, httpmethod, hl, body, multipart, mode, proxy = proxy)
+  return newRequest(url, httpMethod, hl, body, multipart, mode, proxy = proxy)
 
 func createPotentialCORSRequest*(url: URL, destination: RequestDestination, cors: CORSAttribute, fallbackFlag = false): Request =
   var mode = if cors == NO_CORS:
@@ -312,7 +312,7 @@ func newRequest*[T: string|Request](ctx: JSContext, resource: T,
     proxyUrl = init.proxyUrl
   return ok(Request(
     url: url,
-    httpmethod: httpmethod,
+    httpMethod: httpMethod,
     headers: headers,
     body: body,
     multipart: multipart,
f899c87111'>68dff526 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186