diff --git a/library/client/http_client/README.md b/library/client/http_client/README.md new file mode 100644 index 00000000..c070db51 --- /dev/null +++ b/library/client/http_client/README.md @@ -0,0 +1 @@ +Simple HTTP client implemented using Eiffel cURL library diff --git a/library/client/http_client/src/http_client_response.e b/library/client/http_client/src/http_client_response.e index c7f46d28..5fc2cd7e 100644 --- a/library/client/http_client/src/http_client_response.e +++ b/library/client/http_client/src/http_client_response.e @@ -21,6 +21,17 @@ feature {NONE} -- Initialization 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 status: INTEGER assign set_status diff --git a/library/client/http_client/src/http_client_session.e b/library/client/http_client/src/http_client_session.e index 5bb77b74..37cf2e17 100644 --- a/library/client/http_client/src/http_client_session.e +++ b/library/client/http_client/src/http_client_session.e @@ -108,6 +108,11 @@ feature -- Change timeout := n end + set_connect_timeout (n: like connect_timeout) + do + connect_timeout := n + end + set_user_agent (v: READABLE_STRING_8) do add_header ("User-Agent", v) diff --git a/library/client/http_client/src/spec/libcurl/libcurl_http_client_request.e b/library/client/http_client/src/spec/libcurl/libcurl_http_client_request.e index a6ec2f1a..5efa63c6 100644 --- a/library/client/http_client/src/spec/libcurl/libcurl_http_client_request.e +++ b/library/client/http_client/src/spec/libcurl/libcurl_http_client_request.e @@ -15,7 +15,6 @@ inherit session end - create make @@ -174,19 +173,20 @@ feature -- Execution create Result.make l_result := curl_easy.perform (curl_handle) - 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.status := l_http_status + if l_result = {CURL_CODES}.curle_ok then + 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.status := l_http_status + else + Result.status := 0 + end + Result.body := l_curl_string.string else - Result.status := 0 + Result.set_error_occurred (True) end --- last_api_call := l_url curl_easy.cleanup (curl_handle) - - - Result.body := l_curl_string.string end end