blob: d914ab6fc3590f93cd421a9c3d27e3447d61f9ff (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
#
# Character classes
#
rl CTL /0..31 | 127/
rl CR /13/
rl LF /10/
rl SP /32/
rl HT /9/
rl CHAR /0..127/
rl separators / '(' | ')' | '<' | '>'
| '@' | ',' | ';' | ':' | '\\'
| '"' | '/' | '[' | ']' | '?'
| '=' | '{' | '}' | SP | HT /
rl token_char /CHAR - CTL - separators/
#
# Literal tokens
#
literal 'HTTP/', ' ', ':'
token CRLF /CR LF/
#
# Request Line
#
token method /token_char+/
token request_uri /(^SP)+/
token http_number /digit+ '.' digit+/
def http_version
[ 'HTTP/' http_number ]
def request_line
[method ' ' request_uri
' ' http_version CRLF]
#
# Header
#
token field_name /token_char+/
token field_value
/(^(CR|LF) | CR LF (SP|HT))* CR LF/
def header
[field_name ':' field_value]
#
# Request
#
def request
[request_line header* CRLF]
request R = parse_stop request( stdin )
print( 'HTTP/1.0 200 OK\r\n' )
print( 'Date: Fri, 31 Dec 1999 23:59:59 GMT\r\n' )
print( 'Content-Type: text/plain\r\n' )
print( '\r\n' )
print_xml( R )
|