Skip to content

Commit d2d0aaa

Browse files
committed
FIX: patch to prot-http.r to not fail on tiny webserver (http://www.rebol.net/cookbook/recipes/0057.html)
The tiny webserver from Carl uses an incorrect separator between the header and body. This checks for this. Code taken from: metaeducation#807
1 parent d2a06d8 commit d2d0aaa

File tree

1 file changed

+30
-20
lines changed

1 file changed

+30
-20
lines changed

src/mezz/prot-http.r

+30-20
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,23 @@ REBOL [
3030
digit: charset [#"0" - #"9"]
3131
alpha: charset [#"a" - #"z" #"A" - #"Z"]
3232
idate-to-date: function [date [string!]] [
33-
either parse date [
34-
5 skip
35-
copy day: 2 digit
36-
space
37-
copy month: 3 alpha
38-
space
39-
copy year: 4 digit
40-
space
41-
copy time: to space
42-
space
43-
copy zone: to end
44-
][
45-
if zone = "GMT" [zone: copy "+0"]
46-
to date! rejoin [day "-" month "-" year "/" time zone]
47-
][
48-
none
49-
]
33+
either parse date [
34+
5 skip
35+
copy day: 2 digit
36+
space
37+
copy month: 3 alpha
38+
space
39+
copy year: 4 digit
40+
space
41+
copy time: to space
42+
space
43+
copy zone: to end
44+
][
45+
if zone = "GMT" [zone: copy "+0"]
46+
to date! rejoin [day "-" month "-" year "/" time zone]
47+
][
48+
none
49+
]
5050
]
5151
;@@==================================================
5252

@@ -246,11 +246,21 @@ check-response: func [port /local conn res headers d1 d2 line info state awake s
246246
spec: port/spec
247247

248248
;@@net-log ["[HTTP check-response]" info/response-parsed]
249-
249+
250250
if all [
251251
not headers
252-
d1: find conn/data crlfbin
253-
d2: find/tail d1 crlf2bin
252+
any [
253+
all [
254+
d1: find conn/data crlfbin
255+
d2: find/tail d1 crlf2bin
256+
;@@net-log "server using standard content separator of #{0D0A0D0A}"
257+
]
258+
all [
259+
d1: find conn/data #{0A}
260+
d2: find/tail d1 #{0A0A}
261+
;@@net-log "server using malformed line separator of #{0A0A}"
262+
]
263+
]
254264
] [
255265
info/response-line: line: to string! copy/part conn/data d1
256266
info/headers: headers: construct/with d1 http-response-headers

0 commit comments

Comments
 (0)