@@ -173,7 +173,7 @@ def read_line
173173 read_line? or raise EOFError
174174 end
175175
176- def read_request
176+ def read_request_line
177177 return unless line = read_line?
178178
179179 if match = line . match ( REQUEST_LINE )
@@ -182,6 +182,13 @@ def read_request
182182 raise InvalidRequest , line . inspect
183183 end
184184
185+ return method , path , version
186+ end
187+
188+ def read_request
189+ method , path , version = read_request_line
190+ return unless method
191+
185192 headers = read_headers
186193
187194 @persistent = persistent? ( version , method , headers )
@@ -193,11 +200,17 @@ def read_request
193200 return headers . delete ( HOST ) , method , path , version , headers , body
194201 end
195202
196- def read_response ( method )
203+ def read_status_line
197204 version , status , reason = read_line . split ( /\s +/ , 3 )
198205
199206 status = Integer ( status )
200207
208+ return version , status , reason
209+ end
210+
211+ def read_response ( method )
212+ version , status , reason = read_status_line
213+
201214 headers = read_headers
202215
203216 @persistent = persistent? ( version , method , headers )
0 commit comments