Minor correction, to avoid returning 200 as status code, when the client can not connect
This commit is contained in:
@@ -49,7 +49,6 @@ feature -- Execution
|
|||||||
l_curl_string: CURL_STRING
|
l_curl_string: CURL_STRING
|
||||||
l_url: READABLE_STRING_8
|
l_url: READABLE_STRING_8
|
||||||
p: POINTER
|
p: POINTER
|
||||||
a_data: CELL [detachable ANY]
|
|
||||||
l_form, l_last: CURL_FORM
|
l_form, l_last: CURL_FORM
|
||||||
curl: CURL_EXTERNALS
|
curl: CURL_EXTERNALS
|
||||||
curl_easy: CURL_EASY_EXTERNALS
|
curl_easy: CURL_EASY_EXTERNALS
|
||||||
@@ -203,22 +202,32 @@ feature -- Execution
|
|||||||
l_result := curl_easy.perform (curl_handle)
|
l_result := curl_easy.perform (curl_handle)
|
||||||
|
|
||||||
if l_result = {CURL_CODES}.curle_ok then
|
if l_result = {CURL_CODES}.curle_ok then
|
||||||
create a_data.put (Void)
|
Result.status := response_status_code (curl_easy, curl_handle)
|
||||||
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
|
|
||||||
Result.status := l_http_status
|
|
||||||
else
|
|
||||||
Result.status := 0
|
|
||||||
end
|
|
||||||
|
|
||||||
set_header_and_body_to (l_curl_string.string, Result)
|
set_header_and_body_to (l_curl_string.string, Result)
|
||||||
else
|
else
|
||||||
Result.set_error_occurred (True)
|
Result.set_error_occurred (True)
|
||||||
|
Result.status := response_status_code (curl_easy, curl_handle)
|
||||||
end
|
end
|
||||||
|
|
||||||
curl_easy.cleanup (curl_handle)
|
curl_easy.cleanup (curl_handle)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
feature {NONE} -- Implementation
|
||||||
|
|
||||||
|
response_status_code (curl_easy: CURL_EASY_EXTERNALS; curl_handle: POINTER): INTEGER
|
||||||
|
local
|
||||||
|
l_result: INTEGER
|
||||||
|
a_data: CELL [detachable ANY]
|
||||||
|
do
|
||||||
|
create a_data.put (Void)
|
||||||
|
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
|
||||||
|
Result := l_http_status
|
||||||
|
else
|
||||||
|
Result := 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
set_header_and_body_to (a_source: READABLE_STRING_8; res: HTTP_CLIENT_RESPONSE)
|
set_header_and_body_to (a_source: READABLE_STRING_8; res: HTTP_CLIENT_RESPONSE)
|
||||||
-- Parse `a_source' response
|
-- Parse `a_source' response
|
||||||
|
|||||||
Reference in New Issue
Block a user