ftw 0.0.40 → 0.0.41

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.
@@ -34,7 +34,7 @@ class FTW::DNS::DNS
34
34
  if address.length == 16
35
35
  # Unpack 16 bit chunks, convert to hex, join with ":"
36
36
  address.unpack("n8").collect { |p| p.to_s(16) } \
37
- .join(":").sub(/(?:0:(?:0:)+)/, ":")
37
+ .join(":").sub(/(?:^|:)0:(?:0:)+/, "::")
38
38
  else
39
39
  # assume ipv4
40
40
  # Per the following sites, "::127.0.0.1" is valid and correct
@@ -117,7 +117,7 @@ class FTW::HTTP::Headers
117
117
  def each(&block)
118
118
  @headers.each do |field_name, field_value|
119
119
  if field_value.is_a?(Array)
120
- field_value.map { |value| yield field_name, v }
120
+ field_value.map { |value| yield field_name, value }
121
121
  else
122
122
  yield field_name, field_value
123
123
  end
@@ -3,5 +3,5 @@ require "ftw/namespace"
3
3
  # :nodoc:
4
4
  module FTW
5
5
  # The version of this library
6
- VERSION = "0.0.40"
6
+ VERSION = "0.0.41"
7
7
  end
@@ -102,8 +102,8 @@ class FTW::WebSocket
102
102
  def handshake_ok?(response)
103
103
  # See RFC6455 section 4.2.2
104
104
  return false unless response.status == 101 # "Switching Protocols"
105
- return false unless response.headers.get("upgrade") == "websocket"
106
- return false unless response.headers.get("connection") == "Upgrade"
105
+ return false unless response.headers.get("upgrade").downcase == "websocket"
106
+ return false unless response.headers.get("connection").downcase == "upgrade"
107
107
 
108
108
  # Now verify Sec-WebSocket-Accept. It should be the SHA-1 of the
109
109
  # Sec-WebSocket-Key (in base64) + WEBSOCKET_ACCEPT_UUID
@@ -68,8 +68,8 @@ class FTW::WebSocket::Writer
68
68
 
69
69
  # Pack the payload.
70
70
  def pack_payload(data, pack, text, mode)
71
- pack_maskbit_and_length(data, pack, text.length, mode)
72
- pack_extended_length(data, pack, text.length) if text.length >= 126
71
+ pack_maskbit_and_length(data, pack, text.bytesize, mode)
72
+ pack_extended_length(data, pack, text.bytesize) if text.bytesize >= 126
73
73
  if mode == :client
74
74
  mask_key = [rand(1 << 32)].pack("Q")
75
75
  pack_mask(data, pack, mask_key)
@@ -47,4 +47,13 @@ describe FTW::HTTP::Headers do
47
47
  @headers.remove("foo", "two")
48
48
  assert_equal("one", @headers.get("foo"))
49
49
  end
50
+
51
+ test "duplicate headers return multiple key value pairs" do
52
+ @headers.add("foo", "bar")
53
+ @headers.add("foo", "fizz")
54
+ @headers.each do |key, value|
55
+ assert_equal("foo", key)
56
+ assert( value == "bar" || value == "fizz")
57
+ end
58
+ end
50
59
  end # describe FTW::HTTP::Headers
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ftw
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.40
4
+ version: 0.0.41
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jordan Sissel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-22 00:00:00.000000000 Z
11
+ date: 2014-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cabin