@@ -11,14 +11,44 @@ REBOL [
11
11
}
12
12
Name: 'http
13
13
Type: 'module
14
- Version: 0.1.4
14
+ Version: 0.1.5
15
15
File: %prot-http.r
16
16
Purpose: {
17
17
This program defines the HTTP protocol scheme for REBOL 3.
18
18
}
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
+ ]
21
49
]
50
+ ;@@==================================================
51
+
22
52
23
53
sync-op : func [ port body /local state] [
24
54
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
195
225
] [
196
226
info/response-line: line: to string! copy/part conn/data d1
197
227
info/headers: headers: construct /with d1 http-response-headers
198
- info/name: to file! any [ spec/path %/ ]
228
+ info/name: spec/ref
199
229
if headers/content-length [info/size: headers/content-length: to integer! headers/content-length ]
200
230
if headers/last-modified [info/date: attempt [to date! headers/last-modified ]]
201
231
remove/part conn/data d2
@@ -497,7 +527,7 @@ sys/make-scheme [
497
527
connection:
498
528
error: none
499
529
close?: no
500
- info: make port/scheme/info [type: 'file ]
530
+ info: make port/scheme/info [type: 'url ]
501
531
awake: : port/awake
502
532
]
503
533
port/state/connection: conn: make port! compose [
@@ -539,14 +569,19 @@ sys/make-scheme [
539
569
port [port! ]
540
570
/local error state
541
571
] [
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
549
579
]
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 ]
550
585
]
551
586
length? : func [
552
587
port [port! ]
0 commit comments