File tree Expand file tree Collapse file tree 2 files changed +19
-7
lines changed Expand file tree Collapse file tree 2 files changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -64,13 +64,15 @@ def self.[] headers
6464			# Initialize the headers with the specified fields. 
6565			# 
6666			# @parameter fields [Array] An array of `[key, value]` pairs. 
67- 			# @parameter indexed [Hash] A hash table  of normalized headers, if available . 
68- 			def  initialize ( fields  =  [ ] ,  indexed   =  nil ) 
67+ 			# @parameter tail [Integer | Nil] The index  of the trailer start in the @fields array . 
68+ 			def  initialize ( fields  =  [ ] ,  tail   =   nil ,   indexed :  nil ) 
6969				@fields  =  fields 
70- 				@indexed  =  indexed 
7170
72- 				# Marks where trailer start in the @fields array. 
73- 				@tail  =  nil 
71+ 				# Marks where trailer start in the @fields array: 
72+ 				@tail  =  tail 
73+ 				
74+ 				# The cached index of headers: 
75+ 				@indexed  =  nil 
7476			end 
7577
7678			# Initialize a copy of the headers. 
@@ -86,8 +88,8 @@ def initialize_dup(other)
8688			# Clear all headers. 
8789			def  clear 
8890				@fields . clear 
89- 				@indexed  =  nil 
9091				@tail  =  nil 
92+ 				@indexed  =  nil 
9193			end 
9294
9395			# Flatten trailer into the headers, in-place. 
Original file line number Diff line number Diff line change 99describe  Protocol ::HTTP ::Headers  do 
1010	let ( :fields )  do 
1111		[ 
12+ 			[ "connection" ,  "Keep-Alive" ] , 
1213			[ "Content-Type" ,  "text/html" ] , 
1314			[ "Set-Cookie" ,  "hello=world" ] , 
1415			[ "Accept" ,  "*/*" ] , 
1516			[ "set-cookie" ,  "foo=bar" ] , 
16- 			[ "connection" ,  "Keep-Alive" ] 
1717		] 
1818	end 
1919
2020	let ( :headers )  { subject [ fields ] } 
2121
22+ 	with  ".new"  do 
23+ 		it  "can construct headers with trailers"  do 
24+ 			headers  =  subject . new ( fields ,  4 ) 
25+ 			expect ( headers ) . to  be ( :trailer? ) 
26+ 			expect ( headers . trailer . to_a ) . to  be  == [ 
27+ 				[ "set-cookie" ,  "foo=bar" ] , 
28+ 			] 
29+ 		end 
30+ 	end 
31+ 	
2232	with  ".[]"  do 
2333		it  "can be constructed from frozen array"  do 
2434			self . fields . freeze 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments