protocol-http1 0.8.1 → 0.8.2

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: 661cff536d9832701aaf027d558729e8d0e060becd87e07f76d5903bd10813de
4
- data.tar.gz: 3362cd5687c0bcbc5a8774479d8a15a5be0d02ae9acc4dd0651bb1fec4335f1e
3
+ metadata.gz: d23c921f561f2f7a6fb58631aaf830f8e4af6f7256021daa5adc9882f1666431
4
+ data.tar.gz: 1852cbee0e400253d31954a50a756e130843e71fabf513f7f5c0027e2676d153
5
5
  SHA512:
6
- metadata.gz: 467de24fe8851f44b9ff67429fd47fc87b25f048e6914041f63f6332137b22702677627c0d46bd995304ae816a4f4b29f786f8499471ca5838fa942a10ea83e3
7
- data.tar.gz: '068f57168286dfd5db966e59aa6aa35c9164fa3402bd95cb488bc5ba746e2f12c418b46fce3c5f605f7d7c1299a272f3077422daea0fb247f1f88168b4b612bb'
6
+ metadata.gz: b7828fd257625dcf05e8336915425d0be741c773dec2f41966d9c4425431b1631d0f241526579d29c4d2bfa86467727d2aa4cba2b9a8ee3028a65288ed2fc9f2
7
+ data.tar.gz: 8576793707526a79260c8d24f9d18d283e3c90e8c17a8cf8f48ba7a14bf5fd014675e85db923d3bca44e79fc7b9fecc114dc98396ca84806b4e32391eda11355
@@ -43,6 +43,10 @@ module Protocol
43
43
  HOST = 'host'.freeze
44
44
  UPGRADE = 'upgrade'.freeze
45
45
 
46
+ # HTTP/1.x request line parser:
47
+ TOKEN = /[!#$%&'*+-\.^_`|~0-9a-zA-Z]+/.freeze
48
+ REQUEST_LINE = /^(#{TOKEN}) ([^\s]+) (HTTP\/\d.\d)$/.freeze
49
+
46
50
  class Connection
47
51
  CRLF = "\r\n".freeze
48
52
  HTTP10 = "HTTP/1.0".freeze
@@ -147,13 +151,9 @@ module Protocol
147
151
  def read_request
148
152
  return unless line = read_line?
149
153
 
150
- method, path, version = line.split(/\s+/, 3)
151
-
152
- unless HTTP::Methods.const_defined?(method)
153
- raise InvalidMethod, method
154
- end
155
-
156
- unless method and path and version
154
+ if match = line.match(REQUEST_LINE)
155
+ _, method, path, version = *match
156
+ else
157
157
  raise InvalidRequest, line.inspect
158
158
  end
159
159
 
@@ -25,9 +25,6 @@ module Protocol
25
25
  class Error < HTTP::Error
26
26
  end
27
27
 
28
- class InvalidMethod < Error
29
- end
30
-
31
28
  class InvalidRequest < Error
32
29
  end
33
30
 
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Protocol
22
22
  module HTTP1
23
- VERSION = "0.8.1"
23
+ VERSION = "0.8.2"
24
24
  end
25
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protocol-http1
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams