aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2015-10-23 23:46:52 +0900
committerKazuki Yamaguchi <k@rhe.jp>2015-10-23 23:46:57 +0900
commit5c4290f57af852f4b9bae8aba3774dd23f58bd19 (patch)
treea47c6b7fa3c70195997d7c07c29639250aee89db
parentea5a74665b13afb4fe6017d446c0f0314570ae7b (diff)
downloadplum-5c4290f57af852f4b9bae8aba3774dd23f58bd19.tar.gz
freeze constants in order to avoid unexpected modifications
-rw-r--r--lib/plum/connection.rb4
-rw-r--r--lib/plum/errors.rb2
-rw-r--r--lib/plum/frame.rb26
-rw-r--r--lib/plum/hpack/constants.rb6
-rw-r--r--lib/plum/https_connection.rb2
5 files changed, 20 insertions, 20 deletions
diff --git a/lib/plum/connection.rb b/lib/plum/connection.rb
index 0f38e47..e8dc1e8 100644
--- a/lib/plum/connection.rb
+++ b/lib/plum/connection.rb
@@ -6,7 +6,7 @@ module Plum
include FlowControl
include ConnectionUtils
- CLIENT_CONNECTION_PREFACE = "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n"
+ CLIENT_CONNECTION_PREFACE = "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n".freeze
DEFAULT_SETTINGS = {
header_table_size: 4096, # octets
@@ -15,7 +15,7 @@ module Plum
initial_window_size: 65535, # octets; <= 2 ** 31 - 1
max_frame_size: 16384, # octets; <= 2 ** 24 - 1
max_header_list_size: (1 << 32) - 1 # Fixnum
- }
+ }.freeze
attr_reader :hpack_encoder, :hpack_decoder
attr_reader :local_settings, :remote_settings
diff --git a/lib/plum/errors.rb b/lib/plum/errors.rb
index bdf8695..44b711f 100644
--- a/lib/plum/errors.rb
+++ b/lib/plum/errors.rb
@@ -17,7 +17,7 @@ module Plum
enhance_your_calm: 0x0b,
inadequate_security: 0x0c,
http_1_1_required: 0x0d
- }
+ }.freeze
attr_reader :http2_error_type
diff --git a/lib/plum/frame.rb b/lib/plum/frame.rb
index 887bc8b..6520247 100644
--- a/lib/plum/frame.rb
+++ b/lib/plum/frame.rb
@@ -16,37 +16,37 @@ module Plum
goaway: 0x07,
window_update: 0x08,
continuation: 0x09
- }
+ }.freeze
FRAME_FLAGS = {
data: {
end_stream: 0x01,
padded: 0x08
- },
+ }.freeze,
headers: {
end_stream: 0x01,
end_headers: 0x04,
padded: 0x08,
priority: 0x20
- },
- priority: {},
- rst_stream: {},
+ }.freeze,
+ priority: {}.freeze,
+ rst_stream: {}.freeze,
settings: {
ack: 0x01
- },
+ }.freeze,
push_promise: {
end_headers: 0x04,
padded: 0x08
- },
+ }.freeze,
ping: {
ack: 0x01
- },
- goaway: {},
- window_update: {},
+ }.freeze,
+ goaway: {}.freeze,
+ window_update: {}.freeze,
continuation: {
end_headers: 0x04
- }
- }
+ }.freeze
+ }.freeze
SETTINGS_TYPE = {
header_table_size: 0x01,
@@ -55,7 +55,7 @@ module Plum
initial_window_size: 0x04,
max_frame_size: 0x05,
max_header_list_size: 0x06
- }
+ }.freeze
# RFC7540: 4.1 Frame format
# +-----------------------------------------------+
diff --git a/lib/plum/hpack/constants.rb b/lib/plum/hpack/constants.rb
index 5c09a38..1cd3b2b 100644
--- a/lib/plum/hpack/constants.rb
+++ b/lib/plum/hpack/constants.rb
@@ -64,7 +64,7 @@ module Plum
["vary"],
["via"],
["www-authenticate"],
- ]
+ ].freeze
HUFFMAN_TABLE = [
"1111111111000",
@@ -324,8 +324,8 @@ module Plum
"111111111111111111111110000",
"11111111111111111111101110",
"111111111111111111111111111111"
- ]
+ ].freeze
- HUFFMAN_TABLE_INVERSED = HUFFMAN_TABLE.each_with_index.to_h
+ HUFFMAN_TABLE_INVERSED = HUFFMAN_TABLE.each_with_index.to_h.freeze
end
end
diff --git a/lib/plum/https_connection.rb b/lib/plum/https_connection.rb
index 95f2837..82f2f5e 100644
--- a/lib/plum/https_connection.rb
+++ b/lib/plum/https_connection.rb
@@ -26,6 +26,6 @@ module Plum
AECDH-NULL-SHA AECDH-RC4-SHA AECDH-DES-CBC3-SHA AECDH-AES128-SHA AECDH-AES256-SHA SRP-3DES-EDE-CBC-SHA SRP-RSA-3DES-EDE-CBC-SHA SRP-DSS-3DES-EDE-CBC-SHA SRP-AES-128-CBC-SHA SRP-RSA-AES-128-CBC-SHA
SRP-DSS-AES-128-CBC-SHA SRP-AES-256-CBC-SHA SRP-RSA-AES-256-CBC-SHA SRP-DSS-AES-256-CBC-SHA ECDHE-ECDSA-AES128-SHA256 ECDHE-ECDSA-AES256-SHA384 ECDH-ECDSA-AES128-SHA256 ECDH-ECDSA-AES256-SHA384 ECDHE-RSA-AES128-SHA256 ECDHE-RSA-AES256-SHA384
ECDH-RSA-AES128-SHA256 ECDH-RSA-AES256-SHA384 ECDH-ECDSA-AES128-GCM-SHA256 ECDH-ECDSA-AES256-GCM-SHA384 ECDH-RSA-AES128-GCM-SHA256 ECDH-RSA-AES256-GCM-SHA384
- )
+ ).freeze
end
end