http_connection 1.3.1 → 1.4.0

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/README.txt CHANGED
@@ -28,7 +28,7 @@ algorithm for low-level network errors.
28
28
 
29
29
  == INSTALL:
30
30
 
31
- sudo gem install right_http_connection
31
+ gem install http_connection
32
32
 
33
33
  == LICENSE:
34
34
 
@@ -1,160 +1 @@
1
- #
2
- # Copyright (c) 2008 RightScale Inc
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining
5
- # a copy of this software and associated documentation files (the
6
- # "Software"), to deal in the Software without restriction, including
7
- # without limitation the rights to use, copy, modify, merge, publish,
8
- # distribute, sublicense, and/or sell copies of the Software, and to
9
- # permit persons to whom the Software is furnished to do so, subject to
10
- # the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be
13
- # included in all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
- # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
- # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
- # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
- #
23
- #
24
-
25
- # Net::HTTP and Net::HTTPGenericRequest fixes to support 100-continue on
26
- # POST and PUT. The request must have 'expect' field set to '100-continue'.
27
-
28
-
29
- module Net
30
-
31
- class BufferedIO #:nodoc:
32
- # Monkey-patch Net::BufferedIO to read > 1024 bytes from the socket at a time
33
-
34
- # Default size (in bytes) of the max read from a socket into the user space read buffers for socket IO
35
- DEFAULT_SOCKET_READ_SIZE = 16*1024
36
-
37
- @@socket_read_size = DEFAULT_SOCKET_READ_SIZE
38
-
39
- def self.socket_read_size=(readsize)
40
- if(readsize <= 0)
41
- return
42
- end
43
- @@socket_read_size = readsize
44
- end
45
-
46
- def self.socket_read_size?()
47
- @@socket_read_size
48
- end
49
-
50
- def rbuf_fill
51
- timeout(@read_timeout) {
52
- @rbuf << @io.sysread(@@socket_read_size)
53
- }
54
- end
55
- end
56
-
57
-
58
- #-- Net::HTTPGenericRequest --
59
-
60
- class HTTPGenericRequest
61
- # Monkey-patch Net::HTTPGenericRequest to read > 1024 bytes from the local data
62
- # source at a time (used in streaming PUTs)
63
-
64
- # Default size (in bytes) of the max read from a local source (File, String,
65
- # etc.) to the user space write buffers for socket IO.
66
- DEFAULT_LOCAL_READ_SIZE = 16*1024
67
-
68
- @@local_read_size = DEFAULT_LOCAL_READ_SIZE
69
-
70
- def self.local_read_size=(readsize)
71
- if(readsize <= 0)
72
- return
73
- end
74
- @@local_read_size = readsize
75
- end
76
-
77
- def self.local_read_size?()
78
- @@local_read_size
79
- end
80
-
81
- def exec(sock, ver, path, send_only=nil) #:nodoc: internal use only
82
- if @body
83
- send_request_with_body sock, ver, path, @body, send_only
84
- elsif @body_stream
85
- send_request_with_body_stream sock, ver, path, @body_stream, send_only
86
- else
87
- write_header(sock, ver, path)
88
- end
89
- end
90
-
91
- private
92
-
93
- def send_request_with_body(sock, ver, path, body, send_only=nil)
94
- self.content_length = body.bytesize
95
- delete 'Transfer-Encoding'
96
- supply_default_content_type
97
- write_header(sock, ver, path) unless send_only == :body
98
- sock.write(body) unless send_only == :header
99
- end
100
-
101
- def send_request_with_body_stream(sock, ver, path, f, send_only=nil)
102
- unless content_length() or chunked?
103
- raise ArgumentError,
104
- "Content-Length not given and Transfer-Encoding is not `chunked'"
105
- end
106
- supply_default_content_type
107
- write_header(sock, ver, path) unless send_only == :body
108
- unless send_only == :header
109
- if chunked?
110
- while s = f.read(@@local_read_size)
111
- sock.write(sprintf("%x\r\n", s.length) << s << "\r\n")
112
- end
113
- sock.write "0\r\n\r\n"
114
- else
115
- while s = f.read(@@local_read_size)
116
- sock.write s
117
- end
118
- end
119
- end
120
- end
121
- end
122
-
123
-
124
- #-- Net::HTTP --
125
-
126
- class HTTP
127
- def request(req, body = nil, &block) # :yield: +response+
128
- unless started?
129
- start {
130
- req['connection'] ||= 'close'
131
- return request(req, body, &block)
132
- }
133
- end
134
- if proxy_user()
135
- unless use_ssl?
136
- req.proxy_basic_auth proxy_user(), proxy_pass()
137
- end
138
- end
139
- # set body
140
- req.set_body_internal body
141
- begin_transport req
142
- # if we expect 100-continue then send a header first
143
- send_only = ((req.is_a?(Post)||req.is_a?(Put)) && (req['expect']=='100-continue')) ? :header : nil
144
- req.exec @socket, @curr_http_version, edit_path(req.path), send_only
145
- begin
146
- res = HTTPResponse.read_new(@socket)
147
- # if we expected 100-continue then send a body
148
- if res.is_a?(HTTPContinue) && send_only && req['content-length'].to_i > 0
149
- req.exec @socket, @curr_http_version, edit_path(req.path), :body
150
- end
151
- end while res.kind_of?(HTTPContinue)
152
- res.reading_body(@socket, req.response_body_permitted?) {
153
- yield res if block_given?
154
- }
155
- end_transport req, res
156
- res
157
- end
158
- end
159
-
160
- end
1
+ # This was out of date and no longer required.
@@ -26,8 +26,6 @@ require "uri"
26
26
  require "time"
27
27
  require "logger"
28
28
 
29
- $:.unshift(File.dirname(__FILE__))
30
- require "net_fix"
31
29
 
32
30
 
33
31
  module RightHttpConnection #:nodoc:
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http_connection
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
5
4
  prerelease: false
6
5
  segments:
7
6
  - 1
8
- - 3
9
- - 1
10
- version: 1.3.1
7
+ - 4
8
+ - 0
9
+ version: 1.4.0
11
10
  platform: ruby
12
11
  authors:
13
12
  - Travis Reeder
@@ -16,7 +15,7 @@ autorequire:
16
15
  bindir: bin
17
16
  cert_chain: []
18
17
 
19
- date: 2010-09-13 00:00:00 -07:00
18
+ date: 2010-10-17 00:00:00 -07:00
20
19
  default_executable:
21
20
  dependencies: []
22
21
 
@@ -46,7 +45,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
46
45
  requirements:
47
46
  - - ">="
48
47
  - !ruby/object:Gem::Version
49
- hash: 3
50
48
  segments:
51
49
  - 0
52
50
  version: "0"
@@ -55,7 +53,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
55
53
  requirements:
56
54
  - - ">="
57
55
  - !ruby/object:Gem::Version
58
- hash: 3
59
56
  segments:
60
57
  - 0
61
58
  version: "0"