Skip to content

Commit 15f8e47

Browse files
committed
FIX: Query on URL was returning just none
fixes: metaeducation/rebol-issues#467 fixes: metaeducation/rebol-issues#1613
1 parent ae93f76 commit 15f8e47

File tree

1 file changed

+47
-12
lines changed

1 file changed

+47
-12
lines changed

src/mezz/prot-http.r

+47-12
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,44 @@ REBOL [
1111
}
1212
Name: 'http
1313
Type: 'module
14-
Version: 0.1.4
14+
Version: 0.1.5
1515
File: %prot-http.r
1616
Purpose: {
1717
This program defines the HTTP protocol scheme for REBOL 3.
1818
}
19-
Author: ["Gabriele Santilli" "Richard Smolak"]
20-
Date: 26-Nov-2012
19+
Author: ["Gabriele Santilli" "Richard Smolak" "Oldes"]
20+
Date: 10-May-2018
21+
History: [
22+
0.1.1 22-Jun-2007 "Gabriele Santilli" "Version used in R3-Alpha"
23+
0.1.4 26-Nov-2012 "Richard Smolak" "Version from Atronix's fork"
24+
0.1.5 10-May-2018 "Oldes" "FIX: Query on URL was returning just none"
25+
]
26+
]
27+
28+
;@@ idate-to-date should be moved to other location!
29+
digit: charset [#"0" - #"9"]
30+
alpha: charset [#"a" - #"z" #"A" - #"Z"]
31+
idate-to-date: function [date [string!]] [
32+
either parse date [
33+
5 skip
34+
copy day: 2 digit
35+
space
36+
copy month: 3 alpha
37+
space
38+
copy year: 4 digit
39+
space
40+
copy time: to space
41+
space
42+
copy zone: to end
43+
][
44+
if zone = "GMT" [zone: copy "+0"]
45+
to date! rejoin [day "-" month "-" year "/" time zone]
46+
][
47+
none
48+
]
2149
]
50+
;@@==================================================
51+
2252

2353
sync-op: func [port body /local state] [
2454
unless port/state [open port port/state/close?: yes]
@@ -195,7 +225,7 @@ check-response: func [port /local conn res headers d1 d2 line info state awake s
195225
] [
196226
info/response-line: line: to string! copy/part conn/data d1
197227
info/headers: headers: construct/with d1 http-response-headers
198-
info/name: to file! any [spec/path %/]
228+
info/name: spec/ref
199229
if headers/content-length [info/size: headers/content-length: to integer! headers/content-length]
200230
if headers/last-modified [info/date: attempt [to date! headers/last-modified]]
201231
remove/part conn/data d2
@@ -497,7 +527,7 @@ sys/make-scheme [
497527
connection:
498528
error: none
499529
close?: no
500-
info: make port/scheme/info [type: 'file]
530+
info: make port/scheme/info [type: 'url]
501531
awake: :port/awake
502532
]
503533
port/state/connection: conn: make port! compose [
@@ -539,14 +569,19 @@ sys/make-scheme [
539569
port [port!]
540570
/local error state
541571
] [
542-
if state: port/state [
543-
either error? error: state/error [
544-
state/error: none
545-
error
546-
] [
547-
state/info
548-
]
572+
either port/state [
573+
state: port/state
574+
][
575+
open port ;there is port opening in sync-op, but it would also close the port later and so clear the state
576+
attempt [sync-op port [parse-write-dialect port [HEAD]]]
577+
state: port/state
578+
close port
549579
]
580+
if none? state [return none]
581+
either state/info/response-parsed = 'ok [
582+
attempt [ state/info/date: idate-to-date state/info/headers/Last-Modified ]
583+
state/info
584+
][ none ]
550585
]
551586
length?: func [
552587
port [port!]

0 commit comments

Comments
 (0)