http-protocol 0.6.2 → 0.8.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.
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: e259d3cffa653715457b5ecae02b116b4ab063bb837828370ac87d5ae5ec6c70
         | 
| 4 | 
            +
              data.tar.gz: 3e4044515e54d35934d1fa90be3c518c5baee318fe7c01f8237dfb0411076f39
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 8eeddbf50275851a6aa5958cf9efc0f07a004c438b0ef6eb8780819ac1ff5816736d7c0214adbec05d2e387c89f8e3e6077e93913369cac5858139e9168c52b0
         | 
| 7 | 
            +
              data.tar.gz: c05014726647a9fe13f716d119e578f7793e22d496ab29670a3523d5b65cdaed8e5c67114e6614e9c04a41274c2e58cadb2752b89c5e3d73ab33c74e1684f473
         | 
| @@ -91,30 +91,13 @@ module HTTP | |
| 91 91 | 
             
            				self[key] != nil
         | 
| 92 92 | 
             
            			end
         | 
| 93 93 |  | 
| 94 | 
            -
            			# Delete all headers with the given key, and return the value of the last one, if any.
         | 
| 95 | 
            -
            			def delete(key)
         | 
| 96 | 
            -
            				values, @fields = @fields.partition do |field|
         | 
| 97 | 
            -
            					field.first.downcase == key
         | 
| 98 | 
            -
            				end
         | 
| 99 | 
            -
            				
         | 
| 100 | 
            -
            				if @indexed
         | 
| 101 | 
            -
            					@indexed.delete(key)
         | 
| 102 | 
            -
            				end
         | 
| 103 | 
            -
            				
         | 
| 104 | 
            -
            				if field = values.last
         | 
| 105 | 
            -
            					return field.last
         | 
| 106 | 
            -
            				end
         | 
| 107 | 
            -
            			end
         | 
| 108 | 
            -
            			
         | 
| 109 94 | 
             
            			def slice!(keys)
         | 
| 110 95 | 
             
            				values, @fields = @fields.partition do |field|
         | 
| 111 96 | 
             
            					keys.include?(field.first.downcase)
         | 
| 112 97 | 
             
            				end
         | 
| 113 98 |  | 
| 114 | 
            -
            				 | 
| 115 | 
            -
            					 | 
| 116 | 
            -
            						@indexed.delete(key)
         | 
| 117 | 
            -
            					end
         | 
| 99 | 
            +
            				keys.each do |key|
         | 
| 100 | 
            +
            					@indexed.delete(key)
         | 
| 118 101 | 
             
            				end
         | 
| 119 102 | 
             
            			end
         | 
| 120 103 |  | 
| @@ -125,10 +108,8 @@ module HTTP | |
| 125 108 | 
             
            			def []= key, value
         | 
| 126 109 | 
             
            				@fields << [key, value]
         | 
| 127 110 |  | 
| 128 | 
            -
            				 | 
| 129 | 
            -
             | 
| 130 | 
            -
            					merge(@indexed, key.downcase, value)
         | 
| 131 | 
            -
            				end
         | 
| 111 | 
            +
            				# It would be good to do some kind of validation here.
         | 
| 112 | 
            +
            				merge(@indexed, key.downcase, value)
         | 
| 132 113 | 
             
            			end
         | 
| 133 114 |  | 
| 134 115 | 
             
            			MERGE_POLICY = {
         | 
| @@ -159,6 +140,15 @@ module HTTP | |
| 159 140 | 
             
            				'proxy-authenticate' => Multiple
         | 
| 160 141 | 
             
            			}.tap{|hash| hash.default = Split}
         | 
| 161 142 |  | 
| 143 | 
            +
            			# Delete all headers with the given key, and return the merged value.
         | 
| 144 | 
            +
            			def delete(key)
         | 
| 145 | 
            +
            				values, @fields = @fields.partition do |field|
         | 
| 146 | 
            +
            					field.first.downcase == key
         | 
| 147 | 
            +
            				end
         | 
| 148 | 
            +
            				
         | 
| 149 | 
            +
            				return @indexed.delete(key)
         | 
| 150 | 
            +
            			end
         | 
| 151 | 
            +
            			
         | 
| 162 152 | 
             
            			def merge(hash, key, value)
         | 
| 163 153 | 
             
            				if policy = MERGE_POLICY[key]
         | 
| 164 154 | 
             
            					if current_value = hash[key]
         | 
| @@ -175,8 +165,6 @@ module HTTP | |
| 175 165 | 
             
            			end
         | 
| 176 166 |  | 
| 177 167 | 
             
            			def [] key
         | 
| 178 | 
            -
            				@indexed ||= to_h
         | 
| 179 | 
            -
            				
         | 
| 180 168 | 
             
            				@indexed[key]
         | 
| 181 169 | 
             
            			end
         | 
| 182 170 |  | 
| @@ -28,10 +28,9 @@ module HTTP | |
| 28 28 | 
             
            				HTTP10 = "HTTP/1.0".freeze
         | 
| 29 29 | 
             
            				HTTP11 = "HTTP/1.1".freeze
         | 
| 30 30 |  | 
| 31 | 
            -
            				def initialize(stream,  | 
| 31 | 
            +
            				def initialize(stream, persistent = true)
         | 
| 32 32 | 
             
            					@stream = stream
         | 
| 33 33 |  | 
| 34 | 
            -
            					@version = version
         | 
| 35 34 | 
             
            					@persistent = persistent
         | 
| 36 35 |  | 
| 37 36 | 
             
            					@count = 0
         | 
| @@ -39,9 +38,6 @@ module HTTP | |
| 39 38 |  | 
| 40 39 | 
             
            				attr :stream
         | 
| 41 40 |  | 
| 42 | 
            -
            				# The default HTTP version to use (if none specified).
         | 
| 43 | 
            -
            				attr :version
         | 
| 44 | 
            -
            				
         | 
| 45 41 | 
             
            				# Whether the connection is persistent.
         | 
| 46 42 | 
             
            				attr :persistent
         | 
| 47 43 |  | 
| @@ -145,12 +141,11 @@ module HTTP | |
| 145 141 |  | 
| 146 142 | 
             
            					@count += 1
         | 
| 147 143 |  | 
| 148 | 
            -
            					return headers | 
| 144 | 
            +
            					return headers.delete(HOST), method, path, version, headers, body
         | 
| 149 145 | 
             
            				end
         | 
| 150 146 |  | 
| 151 147 | 
             
            				def read_response(method)
         | 
| 152 148 | 
             
            					version, status, reason = read_line.split(/\s+/, 3)
         | 
| 153 | 
            -
            					Async.logger.debug(self) {"#{version} #{status} #{reason}"}
         | 
| 154 149 |  | 
| 155 150 | 
             
            					headers = read_headers
         | 
| 156 151 |  | 
| @@ -357,7 +352,7 @@ module HTTP | |
| 357 352 | 
             
            					# transfer coding (Section 4.1) is the final encoding, the message
         | 
| 358 353 | 
             
            					# body length is determined by reading and decoding the chunked
         | 
| 359 354 | 
             
            					# data until the transfer coding indicates the data is complete.
         | 
| 360 | 
            -
            					if transfer_encoding = headers | 
| 355 | 
            +
            					if transfer_encoding = headers.delete(TRANSFER_ENCODING)
         | 
| 361 356 | 
             
            						# If a message is received with both a Transfer-Encoding and a
         | 
| 362 357 | 
             
            						# Content-Length header field, the Transfer-Encoding overrides the
         | 
| 363 358 | 
             
            						# Content-Length.  Such a message might indicate an attempt to
         | 
| @@ -390,7 +385,7 @@ module HTTP | |
| 390 385 | 
             
            					# the recipient times out before the indicated number of octets are
         | 
| 391 386 | 
             
            					# received, the recipient MUST consider the message to be
         | 
| 392 387 | 
             
            					# incomplete and close the connection.
         | 
| 393 | 
            -
            					if content_length = headers | 
| 388 | 
            +
            					if content_length = headers.delete(CONTENT_LENGTH)
         | 
| 394 389 | 
             
            						length = Integer(content_length)
         | 
| 395 390 | 
             
            						if length >= 0
         | 
| 396 391 | 
             
            							return read_fixed_body(length)
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: http-protocol
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.8.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Samuel Williams
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2018-10- | 
| 11 | 
            +
            date: 2018-10-29 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: http-hpack
         |