Provided a way to report cURL error code back to http_client, via HTTP_CLIENT_RESPONSE

This commit is contained in:
Jocelyn Fiat
2013-02-27 21:49:03 +01:00
parent 598f6df366
commit 92d3f642ac
2 changed files with 17 additions and 4 deletions

View File

@@ -27,6 +27,8 @@ feature -- Status
error_occurred: BOOLEAN
-- Error occurred during request
error_message: detachable READABLE_STRING_8
feature {HTTP_CLIENT_REQUEST} -- Status setting
set_error_occurred (b: BOOLEAN)
@@ -35,6 +37,13 @@ feature {HTTP_CLIENT_REQUEST} -- Status setting
error_occurred := b
end
set_error_message (m: READABLE_STRING_8)
-- Set `error_message' to `m'
do
set_error_occurred (True)
error_message := m
end
feature -- Access
url: STRING_8

View File

@@ -215,7 +215,7 @@ feature -- Execution
Result.status := response_status_code (curl_easy, curl_handle)
set_header_and_body_to (l_curl_string.string, Result)
else
Result.set_error_occurred (True)
Result.set_error_message ("Error: cURL Error[" + l_result.out + "]")
Result.status := response_status_code (curl_easy, curl_handle)
end
@@ -225,10 +225,10 @@ feature -- Execution
curl_easy.cleanup (curl_handle)
else
create Result.make (url)
Result.set_error_occurred (True)
Result.set_error_message ("Error: internal error")
end
--| Remaining cleaning
--| Remaining cleaning
if l_form /= Void then
l_form.dispose
end
@@ -339,7 +339,11 @@ feature {NONE} -- Implementation
--| ex: HTTP/1.1 200 OK%R%N
l_start := l_start + 2
end
if l_start < a_source.count and then a_source[l_start] = '%R' and a_source[l_start + 1] = '%N' then
if l_start = 0 or else
(l_start < a_source.count and then
a_source[l_start] = '%R' and a_source[l_start + 1] = '%N'
)
then
res.set_body (a_source)
else
pos := a_source.substring_index ("%R%N%R%N", l_start)