astro-em-http-request 0.2.9 → 0.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/astro-em-http-request.gemspec +2 -4
- data/ext/http11_client/http11_client.c +43 -2
- data/lib/em-http/client.rb +21 -13
- metadata +2 -4
- data/lib/em_buffer.so +0 -0
- data/lib/http11_client.so +0 -0
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.10
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{astro-em-http-request}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.10"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Ilya Grigorik", "Stephan Maka", "Julien Genestoux"]
|
12
|
-
s.date = %q{2010-04-
|
12
|
+
s.date = %q{2010-04-16}
|
13
13
|
s.description = %q{EventMachine based, async HTTP Request interface}
|
14
14
|
s.email = %q{ilya@igvita.com}
|
15
15
|
s.extensions = ["ext/buffer/extconf.rb", "ext/http11_client/extconf.rb"]
|
@@ -43,8 +43,6 @@ Gem::Specification.new do |s|
|
|
43
43
|
"lib/em-http/mock.rb",
|
44
44
|
"lib/em-http/multi.rb",
|
45
45
|
"lib/em-http/request.rb",
|
46
|
-
"lib/em_buffer.so",
|
47
|
-
"lib/http11_client.so",
|
48
46
|
"spec/fixtures/google.ca",
|
49
47
|
"spec/hash_spec.rb",
|
50
48
|
"spec/helper.rb",
|
@@ -35,6 +35,44 @@ static VALUE rb_hash_lookup(VALUE hash, VALUE key)
|
|
35
35
|
}
|
36
36
|
#endif
|
37
37
|
|
38
|
+
/* Expects upper-case, client_http_field() already does that */
|
39
|
+
static int header_field_needed(VALUE f)
|
40
|
+
{
|
41
|
+
if (RSTRING_LEN(f) < 4) /* Minimum length of one header field */
|
42
|
+
return 0;
|
43
|
+
|
44
|
+
if (strncmp(RSTRING_PTR(f), "CON", 3) == 0)
|
45
|
+
{
|
46
|
+
if (strncmp(RSTRING_PTR(f), "CONTENT_TYPE", RSTRING_LEN(f)) == 0)
|
47
|
+
return 1;
|
48
|
+
if (strncmp(RSTRING_PTR(f), "CONTENT_ENCODING", RSTRING_LEN(f)) == 0)
|
49
|
+
return 1;
|
50
|
+
if (strncmp(RSTRING_PTR(f), "CONTENT_LENGTH", RSTRING_LEN(f)) == 0)
|
51
|
+
return 1;
|
52
|
+
if (strncmp(RSTRING_PTR(f), "CONNECTION", RSTRING_LEN(f)) == 0)
|
53
|
+
return 1;
|
54
|
+
return 0;
|
55
|
+
}
|
56
|
+
else
|
57
|
+
{
|
58
|
+
if (strncmp(RSTRING_PTR(f), "TRANSFER_ENCODING", RSTRING_LEN(f)) == 0)
|
59
|
+
return 1;
|
60
|
+
if (strncmp(RSTRING_PTR(f), "SET_COOKIE", RSTRING_LEN(f)) == 0)
|
61
|
+
return 1;
|
62
|
+
if (strncmp(RSTRING_PTR(f), "LOCATION", RSTRING_LEN(f)) == 0)
|
63
|
+
return 1;
|
64
|
+
if (strncmp(RSTRING_PTR(f), "HOST", RSTRING_LEN(f)) == 0)
|
65
|
+
return 1;
|
66
|
+
if (strncmp(RSTRING_PTR(f), "LAST_MODIFIED", RSTRING_LEN(f)) == 0)
|
67
|
+
return 1;
|
68
|
+
if (strncmp(RSTRING_PTR(f), "ETAG", RSTRING_LEN(f)) == 0)
|
69
|
+
return 1;
|
70
|
+
if (strncmp(RSTRING_PTR(f), "UPGRADE", RSTRING_LEN(f)) == 0)
|
71
|
+
return 1;
|
72
|
+
return 0;
|
73
|
+
}
|
74
|
+
}
|
75
|
+
|
38
76
|
void client_http_field(void *data, const char *field, size_t flen, const char *value, size_t vlen)
|
39
77
|
{
|
40
78
|
char *ch, *end;
|
@@ -56,8 +94,10 @@ void client_http_field(void *data, const char *field, size_t flen, const char *v
|
|
56
94
|
}
|
57
95
|
}
|
58
96
|
|
59
|
-
|
60
|
-
|
97
|
+
if (header_field_needed(f))
|
98
|
+
{
|
99
|
+
el = rb_hash_lookup(req, f);
|
100
|
+
switch(TYPE(el)) {
|
61
101
|
case T_ARRAY:
|
62
102
|
rb_ary_push(el, v);
|
63
103
|
break;
|
@@ -67,6 +107,7 @@ void client_http_field(void *data, const char *field, size_t flen, const char *v
|
|
67
107
|
default:
|
68
108
|
rb_hash_aset(req, f, v);
|
69
109
|
break;
|
110
|
+
}
|
70
111
|
}
|
71
112
|
}
|
72
113
|
|
data/lib/em-http/client.rb
CHANGED
@@ -23,12 +23,12 @@ module EventMachine
|
|
23
23
|
|
24
24
|
# E-Tag
|
25
25
|
def etag
|
26
|
-
self[
|
26
|
+
self[HttpClient::ETAG]
|
27
27
|
end
|
28
28
|
|
29
29
|
def last_modified
|
30
|
-
time = self[
|
31
|
-
Time.parse(time)
|
30
|
+
time = self[HttpClient::LAST_MODIFIED]
|
31
|
+
time ? Time.parse(time) : nil
|
32
32
|
end
|
33
33
|
|
34
34
|
# HTTP response status as an integer
|
@@ -180,17 +180,19 @@ module EventMachine
|
|
180
180
|
include EventMachine::Deferrable
|
181
181
|
include HttpEncoding
|
182
182
|
|
183
|
-
TRANSFER_ENCODING="TRANSFER_ENCODING"
|
184
|
-
CONTENT_ENCODING="CONTENT_ENCODING"
|
185
|
-
CONTENT_LENGTH="CONTENT_LENGTH"
|
186
|
-
KEEP_ALIVE="CONNECTION"
|
187
|
-
SET_COOKIE="SET_COOKIE"
|
188
|
-
LOCATION="LOCATION"
|
189
|
-
HOST="HOST"
|
190
|
-
|
183
|
+
TRANSFER_ENCODING="TRANSFER_ENCODING".freeze
|
184
|
+
CONTENT_ENCODING="CONTENT_ENCODING".freeze
|
185
|
+
CONTENT_LENGTH="CONTENT_LENGTH".freeze
|
186
|
+
KEEP_ALIVE="CONNECTION".freeze
|
187
|
+
SET_COOKIE="SET_COOKIE".freeze
|
188
|
+
LOCATION="LOCATION".freeze
|
189
|
+
HOST="HOST".freeze
|
190
|
+
LAST_MODIFIED="LAST_MODIFIED".freeze
|
191
|
+
ETAG="ETAG".freeze
|
192
|
+
CRLF="\r\n".freeze
|
191
193
|
|
192
194
|
attr_accessor :method, :options, :uri
|
193
|
-
attr_reader :
|
195
|
+
attr_reader :response_header, :errors
|
194
196
|
|
195
197
|
def post_init
|
196
198
|
@max_duration_timer = nil
|
@@ -199,7 +201,7 @@ module EventMachine
|
|
199
201
|
@chunk_header = HttpChunkHeader.new
|
200
202
|
@response_header = HttpResponseHeader.new
|
201
203
|
@parser_nbytes = 0
|
202
|
-
@response =
|
204
|
+
@response = nil
|
203
205
|
@errors = ''
|
204
206
|
@content_decoder = nil
|
205
207
|
@stream = nil
|
@@ -208,6 +210,11 @@ module EventMachine
|
|
208
210
|
@options = {}
|
209
211
|
end
|
210
212
|
|
213
|
+
# Simple getter, because @response is expected to be a String
|
214
|
+
def response
|
215
|
+
@response || ''
|
216
|
+
end
|
217
|
+
|
211
218
|
# start HTTP request once we establish connection to host
|
212
219
|
def connection_completed
|
213
220
|
# if connecting to proxy, then first negotiate the connection
|
@@ -376,6 +383,7 @@ module EventMachine
|
|
376
383
|
if @stream
|
377
384
|
@stream.call(data)
|
378
385
|
else
|
386
|
+
@response ||= ''
|
379
387
|
@response << data
|
380
388
|
end
|
381
389
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: astro-em-http-request
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilya Grigorik
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2010-04-
|
14
|
+
date: 2010-04-16 00:00:00 +02:00
|
15
15
|
default_executable:
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
@@ -60,8 +60,6 @@ files:
|
|
60
60
|
- lib/em-http/mock.rb
|
61
61
|
- lib/em-http/multi.rb
|
62
62
|
- lib/em-http/request.rb
|
63
|
-
- lib/em_buffer.so
|
64
|
-
- lib/http11_client.so
|
65
63
|
- spec/fixtures/google.ca
|
66
64
|
- spec/hash_spec.rb
|
67
65
|
- spec/helper.rb
|
data/lib/em_buffer.so
DELETED
Binary file
|
data/lib/http11_client.so
DELETED
Binary file
|