@@ -157,7 +157,7 @@ make-url: function [
157
157
set value set-word! (append args rejoin [form value #"=" ])
158
158
set value [any-word! | any-string! | number! ] (
159
159
if word? value [value: get :value ]
160
- append args rejoin [value #"&" ]
160
+ append args rejoin [percent /encode form value #"&" ]
161
161
)
162
162
]
163
163
]
@@ -193,13 +193,17 @@ send-request: function [
193
193
] [
194
194
if verbose [
195
195
print ["SEND-REQUEST to" link ", method:" method]
196
+ print ["header:" mold args]
196
197
]
197
198
header: copy # () ; NOTE: CLEAR causes crash later!!!
198
199
if with [extend header args]
199
200
if auth [
201
+ if verbose [print [auth-type mold auth-data]]
200
202
switch auth-type [
201
203
Basic [
202
- Authorization: (rejoin [auth-type space enbase rejoin [first auth-data #":" second auth-data]])
204
+ extend header compose [
205
+ Authorization: (rejoin [auth-type space enbase rejoin [first auth-data #":" second auth-data]])
206
+ ]
203
207
]
204
208
OAuth [
205
209
; TODO: OAuth 1 (see Twitter API)
@@ -212,15 +216,20 @@ send-request: function [
212
216
]
213
217
]
214
218
]
215
- data: reduce [method body-of header]
219
+ ; Make sure all values are strings
220
+ body: body-of header
221
+ forall body [body: next body body/1: form body/1 ]
222
+ data: reduce [method body]
216
223
; if content [append data content]
217
- unless content [content: "" ]
224
+ if any [
225
+ not content
226
+ method = 'GET
227
+ ] [content: "" ]
218
228
append data content
219
229
if verbose [
220
230
print [
221
231
"Link:" link newline
222
232
"Data:" mold data newline
223
- "print here"
224
233
]
225
234
]
226
235
reply: write /info link data
@@ -304,7 +313,7 @@ percent: context [
304
313
reserved-chars: union charset "!*'();:@&=+$,/?#[]" charset "%" ; RFCs are stupid
305
314
unreserved-chars: charset [#"A" - #"Z" #"a" - #"z" #"0" - #"9" "-_.~" ]
306
315
encode : function [
307
- string [string! ]
316
+ string [any- string! ]
308
317
] [
309
318
value: none
310
319
chars: unreserved-chars
0 commit comments