Code cleaning, and nicer output under debug clause
This commit is contained in:
@@ -96,22 +96,6 @@ feature -- Access
|
|||||||
|
|
||||||
feature -- Parsing
|
feature -- Parsing
|
||||||
|
|
||||||
parse_http_request_line (line: STRING)
|
|
||||||
require
|
|
||||||
line /= Void
|
|
||||||
local
|
|
||||||
pos, next_pos: INTEGER
|
|
||||||
do
|
|
||||||
print ("%N parse http request line:%N" + line)
|
|
||||||
-- parse (this should be done by a lexer)
|
|
||||||
pos := line.index_of (' ', 1)
|
|
||||||
method := line.substring (1, pos - 1)
|
|
||||||
next_pos := line.index_of (' ', pos+1)
|
|
||||||
uri := line.substring (pos+1, next_pos-1)
|
|
||||||
ensure
|
|
||||||
not_void_method: method /= Void
|
|
||||||
end
|
|
||||||
|
|
||||||
analyze_request_message (a_input: HTTP_INPUT_STREAM)
|
analyze_request_message (a_input: HTTP_INPUT_STREAM)
|
||||||
require
|
require
|
||||||
input_readable: a_input /= Void and then a_input.is_readable
|
input_readable: a_input /= Void and then a_input.is_readable
|
||||||
@@ -137,14 +121,16 @@ feature -- Parsing
|
|||||||
loop
|
loop
|
||||||
line := a_input.last_string
|
line := a_input.last_string
|
||||||
n := line.count
|
n := line.count
|
||||||
print ("%N" + line + "%N")
|
debug ("nino")
|
||||||
|
print ("%N" + line)
|
||||||
|
end
|
||||||
pos := line.index_of (':',1)
|
pos := line.index_of (':',1)
|
||||||
if pos > 0 then
|
if pos > 0 then
|
||||||
k := line.substring(1, pos-1)
|
k := line.substring (1, pos-1)
|
||||||
if line[pos+1].is_space then
|
if line [pos+1].is_space then
|
||||||
pos := pos + 1
|
pos := pos + 1
|
||||||
end
|
end
|
||||||
if line[n] = '%R' then
|
if line [n] = '%R' then
|
||||||
n := n - 1
|
n := n - 1
|
||||||
end
|
end
|
||||||
val := line.substring (pos + 1, n)
|
val := line.substring (pos + 1, n)
|
||||||
@@ -152,7 +138,7 @@ feature -- Parsing
|
|||||||
end
|
end
|
||||||
txt.append (line)
|
txt.append (line)
|
||||||
txt.append_character ('%N')
|
txt.append_character ('%N')
|
||||||
if line.is_empty or else line[1] = '%R' then
|
if line.is_empty or else line [1] = '%R' then
|
||||||
end_of_stream := True
|
end_of_stream := True
|
||||||
else
|
else
|
||||||
a_input.read_line
|
a_input.read_line
|
||||||
@@ -166,16 +152,21 @@ feature -- Parsing
|
|||||||
local
|
local
|
||||||
pos, next_pos: INTEGER
|
pos, next_pos: INTEGER
|
||||||
do
|
do
|
||||||
print ("%N parse request line:%N" + line)
|
debug ("nino")
|
||||||
|
print ("%N## Parse HTTP request line ##")
|
||||||
|
print ("%N")
|
||||||
|
print (line)
|
||||||
|
end
|
||||||
pos := line.index_of (' ', 1)
|
pos := line.index_of (' ', 1)
|
||||||
method := line.substring (1, pos - 1)
|
method := line.substring (1, pos - 1)
|
||||||
next_pos := line.index_of (' ', pos+1)
|
next_pos := line.index_of (' ', pos + 1)
|
||||||
uri := line.substring (pos+1, next_pos-1)
|
uri := line.substring (pos + 1, next_pos - 1)
|
||||||
version := line.substring (next_pos + 1, line.count)
|
version := line.substring (next_pos + 1, line.count)
|
||||||
ensure
|
ensure
|
||||||
not_void_method: method /= Void
|
not_void_method: method /= Void
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
invariant
|
invariant
|
||||||
request_header_attached: request_header /= Void
|
request_header_attached: request_header /= Void
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user