http 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of http might be problematic. Click here for more details.

@@ -1,17 +0,0 @@
1
- module Http
2
- class Parameters
3
- include Chainable
4
-
5
- def initialize(headers = {})
6
- self.default_headers = headers
7
- end
8
-
9
- def []=(field, value)
10
- default_headers[field.downcase] = value
11
- end
12
-
13
- def [](field)
14
- default_headers[field.downcase]
15
- end
16
- end
17
- end
@@ -1,40 +0,0 @@
1
- %%{
2
-
3
- machine common;
4
-
5
- # ==== TOKENS ====
6
-
7
- CRLF = "\r\n";
8
- CTL = (cntrl | 127);
9
- LWSP = " " | "\t";
10
- LWS = CRLF ? LWSP *;
11
- TEXT = any -- CTL;
12
- LINE = TEXT -- CRLF;
13
- separators = "(" | ")" | "<" | ">" | "@" | "," | ";"
14
- | ":" | "\\" | "\"" | "/" | "[" | "]"
15
- | "?" | "=" | "{" | "}" | " " | "\t"
16
- ;
17
- token = TEXT -- separators;
18
-
19
- # ==== HEADERS ====
20
-
21
- header_sep = LWSP * ":" LWSP *;
22
- header_eol = LWSP * CRLF;
23
- ws_line = LWSP +;
24
- no_ws_line = ( LINE -- LWSP ) + % end_header_value_no_ws;
25
- blank_line = "" % end_header_value_no_ws;
26
- non_blank_line = no_ws_line ( ws_line no_ws_line) * ws_line ?;
27
- header_value_line = ( blank_line | non_blank_line )
28
- > start_header_value_line
29
- % end_header_value_line
30
- ;
31
-
32
- header_value_line_1 = header_value_line CRLF;
33
- header_value_line_n = LWSP + <: header_value_line_1;
34
- header_value = header_value_line_1 header_value_line_n *;
35
- generic_header_name = token +
36
- > start_header_name
37
- % end_header_name;
38
-
39
-
40
- }%%
@@ -1,220 +0,0 @@
1
- %%{
2
- machine http;
3
-
4
- include common "common.rl";
5
-
6
- token_w_sp = token | " " | "\t";
7
- quoted_str = "\"" ((any -- "\"") | ("\\" any)) * "\"";
8
- parameter = token + "=" ( token + | quoted_str );
9
- paramed_val = token * ( ";" ) ?;
10
-
11
- # === HTTP methods
12
- method = "HEAD" % method_head
13
- | "GET" % method_get
14
- | "POST" % method_post
15
- | "PUT" % method_put
16
- | "DELETE" % method_delete
17
- | "CONNECT" % method_connect
18
- | "OPTIONS" % method_options
19
- | "TRACE" % method_trace
20
- | "COPY" % method_copy
21
- | "LOCK" % method_lock
22
- | "MKCOL" % method_mkcol
23
- | "MOVE" % method_move
24
- | "PROPFIND" % method_propfind
25
- | "PROPPATCH" % method_proppatch
26
- | "UNLOCK" % method_unlock
27
- | "REPORT" % method_report
28
- | "MKACTIVITY" % method_mkactivity
29
- | "CHECKOUT" % method_checkout
30
- | "MERGE" % method_merge
31
- | "MSEARCH" % method_msearch
32
- | "NOTIFY" % method_notify
33
- | "SUBSCRIBE" % method_subscribe
34
- | "UNSUBSCRIBE" % method_unsubscribe
35
- | "PATCH" % method_patch
36
- ;
37
-
38
- # === HTTP request URI
39
- request_uri = ( TEXT -- LWSP ) +
40
- > start_uri
41
- % end_uri;
42
-
43
- # === HTTP version
44
- http_version = ( "HTTP/"i ( digit + $ http_major ) "."
45
- ( digit + $ http_minor ) )
46
- > start_version;
47
-
48
-
49
- # === HTTP headers
50
-
51
- header_name = "accept"i % hn_accept
52
- | "accept-charset"i % hn_accept_charset
53
- | "accept-encoding"i % hn_accept_encoding
54
- | "accept-language"i % hn_accept_language
55
- | "accept-ranges"i % hn_accept_ranges
56
- | "age"i % hn_age
57
- | "allow"i % hn_allow
58
- | "authorization"i % hn_authorization
59
- | "cache-control"i % hn_cache_control
60
- | "connection"i % hn_connection
61
- | "content-encoding"i % hn_content_encoding
62
- | "content-language"i % hn_content_language
63
- | "content-length"i % hn_content_length
64
- | "content-location"i % hn_content_location
65
- | "content-md5"i % hn_content_md5
66
- | "content-disposition"i % hn_content_disposition
67
- | "content-range"i % hn_content_range
68
- | "content-type"i % hn_content_type
69
- | "cookie"i % hn_cookie
70
- | "date"i % hn_date
71
- | "dnt"i % hn_dnt
72
- | "etag"i % hn_etag
73
- | "expect"i % hn_expect
74
- | "expires"i % hn_expires
75
- | "from"i % hn_from
76
- | "host"i % hn_host
77
- | "if-match"i % hn_if_match
78
- | "if-modified-since"i % hn_if_modified_since
79
- | "if-none-match"i % hn_if_none_match
80
- | "if-range"i % hn_if_range
81
- | "if-unmodified-since"i % hn_if_unmodified_since
82
- | "keep-alive"i % hn_keep_alive
83
- | "last-modified"i % hn_last_modified
84
- | "link"i % hn_link
85
- | "location"i % hn_location
86
- | "max-forwards"i % hn_max_forwards
87
- | "p3p"i % hn_p3p
88
- | "pragma"i % hn_pragma
89
- | "proxy-authenticate"i % hn_proxy_authenticate
90
- | "proxy-authorization"i % hn_proxy_authorization
91
- | "range"i % hn_range
92
- | "referer"i % hn_referer
93
- | "refresh"i % hn_refresh
94
- | "retry-after"i % hn_retry_after
95
- | "server"i % hn_server
96
- | "set-cookie"i % hn_set_cookie
97
- | "strict-transport-security"i % hn_strict_transport_security
98
- | "te"i % hn_te
99
- | "trailer"i % hn_trailer
100
- | "transfer-encoding"i % hn_transfer_encoding
101
- | "upgrade"i % hn_upgrade
102
- | "user-agent"i % hn_user_agent
103
- | "vary"i % hn_vary
104
- | "via"i % hn_via
105
- | "warning"i % hn_warning
106
- | "www-authenticate"i % hn_www_authenticate
107
- | "x-content-type-options"i % hn_x_content_type_options
108
- | "x-do-not-track"i % hn_x_do_not_track
109
- | "x-forwarded-for"i % hn_x_forwarded_for
110
- | "x-forwarded-proto"i % hn_x_forwarded_proto
111
- | "x-frame-options"i % hn_x_frame_options
112
- | "x-powered-by"i % hn_x_powered_by
113
- | "x-requested-with"i % hn_x_requested_with
114
- | "x-xss-protection"i % hn_x_xss_protection
115
- | generic_header_name
116
- ;
117
-
118
- hdr_generic = header_name
119
- header_sep
120
- header_value
121
- % end_header_value;
122
-
123
-
124
- # Header: Content-Length
125
- # ===
126
- #
127
- content_length_val = digit +
128
- $ count_content_length
129
- % end_content_length
130
- ;
131
-
132
- hdr_content_length = "content-length"i
133
- header_sep
134
- content_length_val $lerr(content_length_err)
135
- header_eol;
136
-
137
- # Header: Transfer-Encoding
138
- # ===
139
- #
140
- hdr_transfer_encoding = "transfer-encoding"i
141
- header_sep
142
- "chunked"i
143
- % end_transfer_encoding_chunked
144
- header_eol;
145
-
146
- # Header: Connection
147
- # ===
148
- # This probably isn't completely right since mutliple tokens
149
- # are permitted in the Connection header.
150
- # http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.10
151
- #
152
- hdr_connection = "connection"i
153
- header_sep
154
- ( "close"i % end_connection_close
155
- | "upgrade"i % end_connection_upgrade )
156
- header_eol;
157
-
158
- # Header: Expect
159
- # ===
160
- #
161
- hdr_expect = "expect"i
162
- header_sep
163
- "100-continue"i
164
- % end_expect_continue
165
- header_eol;
166
-
167
- header = hdr_content_length
168
- | hdr_transfer_encoding
169
- | hdr_connection
170
- | hdr_expect
171
- | hdr_generic
172
- ;
173
-
174
- headers = header *;
175
-
176
- # === HTTP head
177
- request_line = method " " + request_uri ( " " + http_version ) ? CRLF;
178
- exchange_head = ( CRLF * request_line headers CRLF )
179
- > start_head
180
- @ end_head;
181
-
182
- # === HTTP chunked body
183
- chunk_ext = ";" TEXT *;
184
- last_chunk = '0' + chunk_ext ? CRLF;
185
- chunk_size = ( xdigit + - '0' + )
186
- > start_chunk_size
187
- $ count_chunk_size
188
- $! chunk_size_err;
189
-
190
- chunk_head = chunk_size chunk_ext ? CRLF;
191
- chunk_body = any
192
- $ handle_chunk
193
- when handling_body;
194
-
195
- chunk_tail = last_chunk
196
- % last_chunk
197
- ( TEXT + CRLF ) *;
198
-
199
- chunk = chunk_head chunk_body * <: CRLF;
200
-
201
- chunked_body := ( chunk + chunk_tail CRLF )
202
- %to(reset)
203
- $! something_went_wrong;
204
-
205
- # === HTTP identity body
206
- identity_chunk = any
207
- $ handle_body
208
- when handling_body;
209
-
210
- identity_body := identity_chunk *
211
- $! something_went_wrong;
212
-
213
- # === Upgraded connections
214
- upgraded := any * $ handle_message;
215
-
216
- main := exchange_head +
217
- $ count_message_head
218
- $err(something_went_wrong);
219
-
220
- }%%
@@ -1,41 +0,0 @@
1
- %%{
2
-
3
- machine multipart;
4
-
5
- include common "common.rl";
6
-
7
- bchar = alnum | "'" | "(" | ")" | "+" | "_" | ","
8
- | "-" | "." | "/" | ":" | "=" | "?"
9
- ;
10
-
11
-
12
- final = "--" @ end_parts ;
13
- padding = final ? LWSP * CRLF;
14
-
15
- # ==== HEADERS ====
16
- header_name = generic_header_name;
17
- header = header_name header_sep header_value % end_header_value;
18
- headers = header * CRLF;
19
-
20
- multipart =
21
- start:
22
- any * $ peek_delimiter,
23
-
24
- delimiter:
25
- any * $ parse_delimiter,
26
-
27
- head:
28
- padding
29
- headers
30
- > start_head
31
- % end_head
32
- -> body,
33
-
34
- body:
35
- any * $ peek_delimiter,
36
-
37
- epilogue: any *;
38
-
39
- main := multipart $! something_went_wrong;
40
-
41
- }%%