Added error reporting in HTTP_CLIENT_RESPONSE

Added missing set_connect_timeout
This commit is contained in:
Jocelyn Fiat
2011-09-23 18:18:27 +02:00
parent ab1c696837
commit 95ec2e77df
4 changed files with 27 additions and 10 deletions

View File

@@ -0,0 +1 @@
Simple HTTP client implemented using Eiffel cURL library

View File

@@ -21,6 +21,17 @@ feature {NONE} -- Initialization
feature -- Status feature -- Status
error_occurred: BOOLEAN
-- Error occurred during request
feature {HTTP_CLIENT_REQUEST} -- Status setting
set_error_occurred (b: BOOLEAN)
-- Set `error_occurred' to `b'
do
error_occurred := b
end
feature -- Access feature -- Access
status: INTEGER assign set_status status: INTEGER assign set_status

View File

@@ -108,6 +108,11 @@ feature -- Change
timeout := n timeout := n
end end
set_connect_timeout (n: like connect_timeout)
do
connect_timeout := n
end
set_user_agent (v: READABLE_STRING_8) set_user_agent (v: READABLE_STRING_8)
do do
add_header ("User-Agent", v) add_header ("User-Agent", v)

View File

@@ -15,7 +15,6 @@ inherit
session session
end end
create create
make make
@@ -174,6 +173,7 @@ feature -- Execution
create Result.make create Result.make
l_result := curl_easy.perform (curl_handle) l_result := curl_easy.perform (curl_handle)
if l_result = {CURL_CODES}.curle_ok then
create a_data.put (Void) create a_data.put (Void)
l_result := curl_easy.getinfo (curl_handle, {CURL_INFO_CONSTANTS}.curlinfo_response_code, a_data) l_result := curl_easy.getinfo (curl_handle, {CURL_INFO_CONSTANTS}.curlinfo_response_code, a_data)
if l_result = 0 and then attached {INTEGER} a_data.item as l_http_status then if l_result = 0 and then attached {INTEGER} a_data.item as l_http_status then
@@ -181,12 +181,12 @@ feature -- Execution
else else
Result.status := 0 Result.status := 0
end end
-- last_api_call := l_url
curl_easy.cleanup (curl_handle)
Result.body := l_curl_string.string Result.body := l_curl_string.string
else
Result.set_error_occurred (True)
end
curl_easy.cleanup (curl_handle)
end end
end end