Skip to content

Commit a82f6a9

Browse files
committed
http: Add URL encoding of query string fields and values
1 parent aeb996f commit a82f6a9

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/http.q

+16-1
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,23 @@
183183

184184
urlPath:urlParts`path;
185185

186+
if["?" in urlPath;
187+
urlArgs:last "?" vs urlPath;
188+
urlArgs:"=" vs/: "&" vs urlArgs;
189+
190+
if[not all 2 = count each urlArgs;
191+
.log.error "URL query string is invalid, must be ampersand separated 'key=value' pairs [ URL: ",urlParts[`path]," ]";
192+
'"InvalidUrlQueryStringException";
193+
];
194+
195+
urlArgs:.h.hu@/:/: urlArgs;
196+
urlArgs:"&" sv "=" sv/: urlArgs;
197+
198+
urlPath:first["?" vs urlPath],"?",urlArgs;
199+
];
200+
186201
if[urlParts`proxy;
187-
urlPath:raze urlParts`scheme`baseUrl`path;
202+
urlPath:raze urlParts[`scheme`baseUrl],urlPath;
188203
];
189204

190205
if[0 < count body;

0 commit comments

Comments
 (0)