Updated README.md with configuration topics related to libcurl or net disabling.
Fixed ssl test by precising insecure ssl.
This commit is contained in:
@@ -1,14 +1,56 @@
|
|||||||
# simple HTTP client
|
# simple HTTP client
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
|
It provides simple routine to perform http requests, and get response.
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
* Eiffel cURL library
|
* One of the following
|
||||||
* cURL dynamic libraries in the PATH or the current directory (.dll or .so)
|
- Eiffel cURL library
|
||||||
|
- cURL dynamic libraries in the PATH or the current directory (.dll or .so)
|
||||||
|
- Eiffel Net library
|
||||||
|
- and optionally Eiffel NetSSL library to support https://
|
||||||
|
|
||||||
This means on Windows, do not forget to copy the libcurl.dll (and related) either in the same directory of the executable, or ensure the .dll are in the PATH environment.
|
This means on Windows, do not forget to copy the libcurl.dll (and related) either in the same directory of the executable, or ensure the .dll are in the PATH environment.
|
||||||
|
|
||||||
|
It is possible to exclude the libcurl implementation xor the Eiffel Net implementation:
|
||||||
|
In the .ecf configuration file of your project, you can use the following custom variables:
|
||||||
|
|
||||||
|
* Disable the libcurl implementation
|
||||||
|
```
|
||||||
|
<variable name="libcurl_http_client_disabled" value="True"/>
|
||||||
|
```
|
||||||
|
|
||||||
|
* Disable the net implementation
|
||||||
|
```
|
||||||
|
<variable name="net_http_client_disabled" value="True"/>
|
||||||
|
```
|
||||||
|
|
||||||
|
* If you disabled both, the http client will not work as expected.
|
||||||
|
|
||||||
|
For the net implementation (using EiffelNet), if you need https:// support, you need to enabled the ssl support with the custom variables :
|
||||||
|
```
|
||||||
|
<variable name="netssl_http_client_enabled" value="True"/>
|
||||||
|
```
|
||||||
|
* By default, SSL is not included (mostly because it is sometime a pain to get the needed dynamic libraries .dll or .so)
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
* To build code that is portable across the libcurl or net implementation of http_client library, use the DEFAULT_HTTP_CLIENT
|
||||||
|
|
||||||
|
```
|
||||||
|
cl: DEFAULT_HTTP_CLIENT
|
||||||
|
sess: HTTP_CLIENT_SESSION
|
||||||
|
create cl
|
||||||
|
sess := cl.new_session ("http://example.com")
|
||||||
|
if attached sess.get ("/path-to-test") as l_response then
|
||||||
|
if not l_response.error_occurred then
|
||||||
|
if attached l_response.body as l_body then
|
||||||
|
print (l_body)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
* See the tests/test-safe.ecf project to see how to use.
|
||||||
|
* Examples will come in the future.
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ feature -- Test routines
|
|||||||
h: STRING_8
|
h: STRING_8
|
||||||
do
|
do
|
||||||
sess := new_session ("https://www.eiffel.org")
|
sess := new_session ("https://www.eiffel.org")
|
||||||
|
sess.set_is_insecure (True)
|
||||||
if attached sess.get ("/welcome", Void) as res then
|
if attached sess.get ("/welcome", Void) as res then
|
||||||
assert ("Get returned without error", not res.error_occurred)
|
assert ("Get returned without error", not res.error_occurred)
|
||||||
create h.make_empty
|
create h.make_empty
|
||||||
|
|||||||
Reference in New Issue
Block a user