http 1.0.0.pre4 → 1.0.0.pre5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9b68e3604886c916e6e4f1fd3607704c781d5895
4
- data.tar.gz: e7ec1fece7b666199c2f5dab353530c0669a512a
3
+ metadata.gz: 5ee1ca0916164aded3b9b12560622a11207255cd
4
+ data.tar.gz: 441afd2c8d51450678c3520459f9d21007a306cf
5
5
  SHA512:
6
- metadata.gz: 642f976768af7e7bbebf7e8a1639c539bd168001b0dd7b1bf0369fe310a0ba94a15a377a14ae7d9725c08c4d45af1e8d2fbaecb1fa72591718e740a455e47a3f
7
- data.tar.gz: 299d773b6b6ca345116fa3c2d2f87d8e55fe2203af198fb7ab4af1c09d8c550a2cac88ba4fcc3ec59a86e32969cec41dfe91b7ae2383ae73ff8dbad0fe51b616
6
+ metadata.gz: f22db552865424b796f4cf2c96e4b285befee9397825a8cfc8cf389d0c6f98adb0f701dd46cf60449f017f54b76d6196cd5f4c9df547b629fedd3ab7bfb56275
7
+ data.tar.gz: 38b12a78b17f7fa5b97a0f89a25e5d44c282895dc73871dd39dc2548d4d2734eb04379ff6738dcf6567b0231cf6afe13084637b1cea662fb61c231aa17b86da2
data/CHANGES.md CHANGED
@@ -35,9 +35,13 @@
35
35
  ([@tarcieri])
36
36
 
37
37
  * [#278](https://github.com/httprb/http/pull/278)
38
- Use an options hash for HTTP::Request's initializer API.
38
+ Use an options hash for HTTP::Request initializer API.
39
39
  ([@ixti])
40
40
 
41
+ * [#279](https://github.com/httprb/http/pull/279)
42
+ Send headers and body in one write if possible.
43
+ This avoids a pathological case in Nagle's algorithm.
44
+ ([@tarcieri])
41
45
 
42
46
  ## 0.9.8 (2015-09-29)
43
47
 
@@ -36,8 +36,9 @@ module HTTP
36
36
 
37
37
  # Stream the request to a socket
38
38
  def stream
39
- send_request_header
40
- send_request_body
39
+ add_headers
40
+ add_body_type_headers
41
+ send_request
41
42
  end
42
43
 
43
44
  # Send headers needed to connect through proxy
@@ -64,23 +65,24 @@ module HTTP
64
65
  @request_header.join(CRLF) + (CRLF) * 2
65
66
  end
66
67
 
67
- def send_request_header
68
- add_headers
69
- add_body_type_headers
68
+ def send_request
69
+ headers = join_headers
70
70
 
71
- write(join_headers)
72
- end
71
+ case @body
72
+ when NilClass
73
+ write(headers)
74
+ when String
75
+ write(headers << @body)
76
+ when Enumerable
77
+ write(headers)
73
78
 
74
- def send_request_body
75
- if @body.is_a?(String)
76
- write(@body)
77
- elsif @body.is_a?(Enumerable)
78
79
  @body.each do |chunk|
79
80
  write(chunk.bytesize.to_s(16) << CRLF)
80
81
  write(chunk << CRLF)
81
82
  end
82
83
 
83
84
  write(CHUNKED_END)
85
+ else fail TypeError, "invalid body type: #{@body.class}"
84
86
  end
85
87
  end
86
88
 
data/lib/http/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module HTTP
2
- VERSION = "1.0.0.pre4".freeze
2
+ VERSION = "1.0.0.pre5".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre4
4
+ version: 1.0.0.pre5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Arcieri
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2015-12-19 00:00:00.000000000 Z
14
+ date: 2015-12-20 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: http_parser.rb