Removed WGI_RESPONSE.write (..)

Replaced any internal call to WGI_RESPONSE.write () by the associated implementation (i.e  output.put_string (...)  )
Added WGI_OUTPUT_STREAM.put_crlf

Renamed WSF_RESPONSE.put_response (a_message) as  `send (a_message)'
WSF_RESPONSE_MESSAGE.send_to (res)  is now exported only to WSF_RESPONSE
This commit is contained in:
Jocelyn Fiat
2012-03-19 14:52:12 +01:00
parent 84a12447db
commit fea0f115a0
13 changed files with 61 additions and 42 deletions

View File

@@ -1,6 +1,5 @@
note
description: "Summary description for {WGI_NINO_CONNECTOR}."
author: ""
date: "$Date$"
revision: "$Revision$"
@@ -127,7 +126,7 @@ feature -- Server
end
note
copyright: "2011-2012, Eiffel Software and others"
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -21,19 +21,24 @@ create
feature -- Header output operation
put_header_text (a_text: READABLE_STRING_8)
local
o: like output
do
write (a_text)
o := output
o.put_string (a_text)
-- Nino does not support persistent connection for now
write ("Connection: close")
write (crlf)
o.put_string ("Connection: close")
o.put_crlf
-- end of headers
write (crlf)
o.put_crlf
header_committed := True
end
;note
copyright: "2011-2012, Eiffel Software and others"
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -42,14 +42,6 @@ feature -- Status report
deferred
end
feature {WGI_RESPONSE} -- Core output operation
write (s: READABLE_STRING_8)
-- Send the string `s'
-- this can be used for header and body
deferred
end
feature -- Status setting
status_is_set: BOOLEAN

View File

@@ -48,15 +48,6 @@ feature -- Status report
Result := status_is_set and header_committed
end
feature {NONE} -- Core output operation
write (s: READABLE_STRING_8)
-- Send the content of `s'
-- this can be used for header and body
do
output.put_string (s)
end
feature -- Status setting
status_is_set: BOOLEAN
@@ -81,8 +72,8 @@ feature -- Header output operation
put_header_text (a_text: READABLE_STRING_8)
do
write (a_text)
write (crlf)
output.put_string (a_text)
output.put_crlf
header_committed := True
end
@@ -126,9 +117,6 @@ feature -- Output operation
feature {NONE} -- Implementation: Access
crlf: STRING = "%R%N"
-- End of header
output: WGI_OUTPUT_STREAM
-- Server output channel

View File

@@ -52,7 +52,13 @@ feature -- Specific output
-- Send `s' to http client as header line
do
put_string (s)
put_string ("%R%N")
put_crlf
end
put_crlf
-- Send "%R%N" string
do
put_string (crlf)
end
feature -- Status writing
@@ -80,6 +86,10 @@ feature -- Basic operations
deferred
end
feature -- Constant
crlf: STRING = "%R%N"
note
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"

View File

@@ -185,7 +185,7 @@ feature -- Execution
fres.set_status_code ({HTTP_STATUS_CODE}.ok)
fres.set_answer_head_request_method (req.request_method.same_string ({HTTP_REQUEST_METHODS}.method_head))
res.put_response (fres)
res.send (fres)
end
respond_not_found (uri: READABLE_STRING_8; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)

View File

@@ -32,7 +32,7 @@ feature -- Implementation
execute (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
-- Execute request handler
do
response (ctx, req).send_to (res)
res.send (response (ctx, req))
end
note

View File

@@ -150,7 +150,7 @@ feature -- Element change
update_content_length
end
feature -- Basic operations
feature {WSF_RESPONSE} -- Output
send_to (res: WSF_RESPONSE)
local

View File

@@ -110,7 +110,7 @@ feature -- Element change
body := b
end
feature -- Output
feature {WSF_RESPONSE} -- Output
send_to (res: WSF_RESPONSE)
local

View File

@@ -1,5 +1,7 @@
note
description: "Summary description for {WSF_PAGE_RESPONSE}."
description: "[
]"
author: ""
date: "$Date$"
revision: "$Revision$"
@@ -77,7 +79,7 @@ feature -- Element change
l_body.append (a_string)
end
feature -- Output
feature {WSF_RESPONSE} -- Output
send_to (res: WSF_RESPONSE)
local

View File

@@ -69,7 +69,7 @@ feature -- Element change
content_type := Void
end
feature -- Output
feature {WSF_RESPONSE} -- Output
send_to (res: WSF_RESPONSE)
local

View File

@@ -187,15 +187,31 @@ feature -- Output operation
feature -- Response object
put_response (obj: WSF_RESPONSE_MESSAGE)
-- Set `obj' as the whole response to the client
--| `obj' is responsible to sent the status code, the header and the content
put_response (a_message: WSF_RESPONSE_MESSAGE)
-- Set `a_message' as the whole response to the client
--| `a_message' is responsible to sent the status code, the header and the content
obsolete
"[2012-Mars-19] Use `send (a_message)' "
require
header_not_committed: not header_committed
status_not_committed: not status_committed
no_message_committed: not message_committed
do
obj.send_to (Current)
a_message.send_to (Current)
ensure
status_committed: status_committed
header_committed: header_committed
end
send (a_message: WSF_RESPONSE_MESSAGE)
-- Set `a_message' as the whole response to the client
--| `a_message' is responsible to sent the status code, the header and the content
require
header_not_committed: not header_committed
status_not_committed: not status_committed
no_message_committed: not message_committed
do
a_message.send_to (Current)
ensure
status_committed: status_committed
header_committed: header_committed

View File

@@ -7,10 +7,17 @@ note
deferred class
WSF_RESPONSE_MESSAGE
feature -- Output
feature {WSF_RESPONSE} -- Output
send_to (res: WSF_RESPONSE)
require
header_not_committed: not res.header_committed
status_not_committed: not res.status_committed
no_message_committed: not res.message_committed
deferred
ensure
res_status_set: res.status_is_set
res_header_committed: res.header_committed
end
note