Now WGI_RESPONSE.set_status_code (..) has a new argument to pass optional custom reason phrase.

This is a minor breaking change (but prior to the first release, so acceptable)
   And then it is now possible to precise a custom reason phrase (useful for 4xx and 5xx response)

At the WSF_RESPONSE level, the status code is now sent only when the header are sent.
thus, it is possible to change the status code as long as no header is sent.
(in the future, we should also try to delay the sending of headers)

Removed WGI_RESPONSE.put_header_lines (..) which was not used, and WGI is not meant to provide such user friendly features
Now this is available directly on WSF_RESPONSE
This commit is contained in:
Jocelyn Fiat
2012-04-12 11:19:41 +02:00
parent 082def2b70
commit b541efcc8f
14 changed files with 149 additions and 70 deletions

View File

@@ -92,6 +92,11 @@ feature -- Authentication
Result := session.credentials
end
proxy: detachable TUPLE [host: READABLE_STRING_8; port: INTEGER]
do
Result := session.proxy
end
feature -- Settings
timeout: INTEGER
@@ -131,6 +136,12 @@ feature -- Settings
Result := session.default_response_charset
end
is_insecure: BOOLEAN
-- Allow connections to SSL sites without certs
do
Result := session.is_insecure
end
feature {NONE} -- Utilities
append_parameters_to_url (a_url: STRING; a_parameters: detachable ARRAY [detachable TUPLE [name: READABLE_STRING_8; value: READABLE_STRING_8]])

View File

@@ -105,6 +105,12 @@ feature -- Settings
default_response_charset: detachable READABLE_STRING_8
-- Default encoding of responses. Used if no charset is provided by the host.
is_insecure: BOOLEAN
-- Allow connections to SSL sites without certs
proxy: detachable TUPLE [host: READABLE_STRING_8; port: INTEGER]
-- Proxy information [`host' and `port']
feature -- Access
base_url: READABLE_STRING_8
@@ -132,9 +138,9 @@ feature -- Change
base_url := u
end
set_timeout (n: like timeout)
set_timeout (n_seconds: like timeout)
do
timeout := n
timeout := n_seconds
end
set_connect_timeout (n: like connect_timeout)
@@ -147,6 +153,11 @@ feature -- Change
add_header ("User-Agent", v)
end
set_is_insecure (b: BOOLEAN)
do
is_insecure := b
end
add_header (k: READABLE_STRING_8; v: READABLE_STRING_8)
do
headers.force (v, k)
@@ -203,6 +214,15 @@ feature -- Change
max_redirects := n
end
set_proxy (a_host: detachable READABLE_STRING_8; a_port: INTEGER)
do
if a_host = Void then
proxy := Void
else
proxy := [a_host, a_port]
end
end
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

@@ -54,6 +54,7 @@ feature -- Execution
curl_easy: CURL_EASY_EXTERNALS
curl_handle: POINTER
ctx: like context
l_proxy: like proxy
do
ctx := context
curl := session.curl
@@ -83,7 +84,14 @@ feature -- Execution
curl_easy.setopt_integer (curl_handle, {CURL_OPT_CONSTANTS}.curlopt_header, 1)
--| PROXY ...
if ctx /= Void and then attached ctx.proxy as l_proxy then
if ctx /= Void then
l_proxy := ctx.proxy
end
if l_proxy = Void then
l_proxy := proxy
end
if l_proxy /= Void then
curl_easy.setopt_integer (curl_handle, {CURL_OPT_CONSTANTS}.curlopt_proxyport, l_proxy.port)
curl_easy.setopt_string (curl_handle, {CURL_OPT_CONSTANTS}.curlopt_proxy, l_proxy.host)
end
@@ -104,6 +112,12 @@ feature -- Execution
curl_easy.setopt_integer (curl_handle, {CURL_OPT_CONSTANTS}.curlopt_followlocation, 0)
end
--| SSL
if is_insecure then
curl_easy.setopt_integer (curl_handle, {CURL_OPT_CONSTANTS}.curlopt_ssl_verifyhost, 0)
curl_easy.setopt_integer (curl_handle, {CURL_OPT_CONSTANTS}.curlopt_ssl_verifypeer, 0)
end
if request_method.is_case_insensitive_equal ("GET") then
curl_easy.setopt_integer (curl_handle, {CURL_OPT_CONSTANTS}.curlopt_httpget, 1)
elseif request_method.is_case_insensitive_equal ("POST") then