A few change to make it more customizable

and prepare integration to EiffelWebReloaded (see on github)
This commit is contained in:
Jocelyn Fiat
2011-05-26 17:23:21 +02:00
parent 85cf39f3c6
commit 64cf2b6936
23 changed files with 590 additions and 298 deletions

View File

@@ -2,12 +2,38 @@
class HTTP_RESPONSE
inherit
HTTP_CONSTANTS
redefine
default_create
end
create
default_create
make
feature -- creation
default_create
do
Precursor
set_defaults
end
set_defaults
-- Set default values for the reply
do
status_code := ok
create content_length_data.make_empty
reason_phrase := ok_message
content_type_data := text_html
set_reply_text (Void)
end
feature -- Recycle
reset
do
set_defaults
end
feature -- response header fields
@@ -17,11 +43,19 @@ feature -- response header fields
content_length_data : STRING
-- length
set_content_length (new_content_length: STRING)
reason_phrase: STRING
-- message, if any
content_type_data: STRING
-- type of content in this reply (eg. text/html)
feature -- Element change
set_content_length (new_content_length: INTEGER)
require
not_void: new_content_length /= Void
positive_or_zero: new_content_length >= 0
do
content_length_data := new_content_length
content_length_data := new_content_length.out
end
set_status_code (new_status_code: STRING)
@@ -31,9 +65,6 @@ feature -- response header fields
status_code := new_status_code
end
reason_phrase: STRING
-- message, if any
set_reason_phrase (new_reason_phrase: STRING)
require
not_void: new_reason_phrase /= Void
@@ -41,9 +72,6 @@ feature -- response header fields
reason_phrase := new_reason_phrase
end
content_type_data: STRING
-- type of content in this reply (eg. text/html)
set_content_type (new_content_type: STRING)
require
not_void: new_content_type /= Void
@@ -51,18 +79,7 @@ feature -- response header fields
content_type_data := new_content_type
end
feature -- creation
make
do
-- set default values for the reply
status_code := ok
reason_phrase := ok_message
content_type_data := text_html
end
feature -- access these to send a reply
feature -- Access: send reply
reply_header: STRING
-- header
@@ -73,7 +90,7 @@ feature -- access these to send a reply
Result.extend (' ')
Result.append (reason_phrase)
Result.append (crlf)
Result.append (Server_datails)
Result.append ({HTTP_SERVER_CONFIGURATION}.Server_details)
Result.append (crlf)
Result.append (Content_type + ": ")
Result.append (content_type_data)
@@ -89,7 +106,7 @@ feature -- access these to send a reply
reply_header_continue: STRING
-- header
do
Result :=http_version_1_1.twin
Result := http_version_1_1.twin
Result.extend (' ')
Result.append (status_code)
Result.extend (' ')
@@ -100,14 +117,19 @@ feature -- access these to send a reply
-- then keep the connection alive
end
reply_text: STRING
-- reply text
set_reply_text (new_text: STRING)
feature -- Change element: send reply
set_reply_text (new_text: detachable STRING)
-- text could be Void
do
reply_text := new_text
if new_text = Void then
create reply_text.make_empty
else
reply_text := new_text
end
end
append_reply_text (more_text: STRING)