diff --git a/library/client/http_client/http_client-safe.ecf b/library/client/http_client/http_client-safe.ecf
index 8ff790a5..de757e10 100644
--- a/library/client/http_client/http_client-safe.ecf
+++ b/library/client/http_client/http_client-safe.ecf
@@ -10,6 +10,7 @@
+
@@ -23,17 +24,4 @@
-
-
-
- /.git$
- /EIFGENs$
- /.svn$
-
-
-
-
-
diff --git a/library/client/http_client/http_client.ecf b/library/client/http_client/http_client.ecf
index ee034729..a4ec1415 100644
--- a/library/client/http_client/http_client.ecf
+++ b/library/client/http_client/http_client.ecf
@@ -10,6 +10,7 @@
+
diff --git a/library/client/http_client/src/http_client_session.e b/library/client/http_client/src/http_client_session.e
index d4c02ef1..d8245b9d 100644
--- a/library/client/http_client/src/http_client_session.e
+++ b/library/client/http_client/src/http_client_session.e
@@ -1,12 +1,29 @@
note
- description : "Objects that ..."
- author : "$Author$"
- date : "$Date$"
- revision : "$Revision$"
+ description : "[
+ HTTP_CLIENT_SESSION represent a session
+ and is used to call get, post, .... request
+ with predefined settings such as
+ base_url
+ specific common headers
+ timeout and so on ...
+ ]"
+ author: "$Author$"
+ date: "$Date$"
+ revision: "$Revision$"
deferred class
HTTP_CLIENT_SESSION
+inherit
+ ANY
+
+ HTTP_CLIENT_CONSTANTS
+ rename
+ auth_type_id as auth_type_id_from_string
+ export
+ {NONE} all
+ end
+
feature {NONE} -- Initialization
make (a_base_url: READABLE_STRING_8)
@@ -154,37 +171,36 @@ feature -- Change
set_auth_type (s: READABLE_STRING_8)
do
auth_type := s
- auth_type_id := http_client_constants.auth_type_id (s)
+ auth_type_id := auth_type_id_from_string (s)
end
set_basic_auth_type
do
auth_type := "basic"
- auth_type_id := {HTTP_CLIENT_CONSTANTS}.auth_type_basic
+ auth_type_id := Auth_type_basic
end
set_digest_auth_type
do
auth_type := "digest"
- auth_type_id := {HTTP_CLIENT_CONSTANTS}.auth_type_digest
+ auth_type_id := Auth_type_digest
end
set_any_auth_type
do
auth_type := "any"
- auth_type_id := {HTTP_CLIENT_CONSTANTS}.auth_type_any
+ auth_type_id := Auth_type_any
end
set_anysafe_auth_type
do
auth_type := "anysafe"
- auth_type_id := {HTTP_CLIENT_CONSTANTS}.auth_type_anysafe
+ auth_type_id := Auth_type_anysafe
end
-feature {NONE} -- Implementation
-
- http_client_constants: HTTP_CLIENT_CONSTANTS
- once
- create Result
+ set_max_redirects (n: like max_redirects)
+ do
+ max_redirects := n
end
+
end
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 fb3c7c90..520f9fc4 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
@@ -24,6 +24,15 @@ feature {NONE} -- Initialization
do
make_request (a_url, a_session, ctx)
request_method := a_request_method
+ apply_workaround
+ end
+
+ apply_workaround
+ -- Due to issue with Eiffel cURL on Windows 32bits
+ -- we need to do the following workaround
+ once
+ if attached (create {INET_ADDRESS_FACTORY}).create_localhost then
+ end
end
session: LIBCURL_HTTP_CLIENT_SESSION
diff --git a/library/client/http_client/tests/test-safe.ecf b/library/client/http_client/tests/test-safe.ecf
new file mode 100644
index 00000000..6c32920a
--- /dev/null
+++ b/library/client/http_client/tests/test-safe.ecf
@@ -0,0 +1,18 @@
+
+
+
+
+
+ /.git$
+ /EIFGENs$
+ /.svn$
+
+
+
+
+
+
+
+
diff --git a/library/client/http_client/tests/test.e b/library/client/http_client/tests/test.e
new file mode 100644
index 00000000..0073561a
--- /dev/null
+++ b/library/client/http_client/tests/test.e
@@ -0,0 +1,50 @@
+class TEST
+
+create
+ make
+
+feature -- Init
+
+ make
+ do
+ test_http_client
+ end
+
+ test_http_client
+ -- New test routine
+ local
+ sess: LIBCURL_HTTP_CLIENT_SESSION
+ h: STRING_8
+ do
+ create sess.make ("http://www.google.com")
+ if attached sess.get ("/search?q=eiffel", Void) as res then
+ assert ("Get returned without error", not res.error_occurred)
+ create h.make_empty
+ if attached res.headers as hds then
+ across
+ hds as c
+ loop
+ h.append (c.item.name + ": " + c.item.value + "%R%N")
+ end
+ end
+ if attached res.body as l_body then
+ assert ("body not empty", not l_body.is_empty)
+ end
+ assert ("same headers", h.same_string (res.raw_header))
+ else
+ assert ("Not found", False)
+ end
+ end
+
+ assert (m: READABLE_STRING_8; b: BOOLEAN)
+ local
+ e: DEVELOPER_EXCEPTION
+ do
+ if not b then
+ create e
+ e.set_message (m)
+ e.raise
+ end
+ end
+
+end
diff --git a/library/client/http_client/tests/test_http_client.e b/library/client/http_client/tests/test_http_client.e
index 655a3966..a5cf2228 100644
--- a/library/client/http_client/tests/test_http_client.e
+++ b/library/client/http_client/tests/test_http_client.e
@@ -23,6 +23,7 @@ feature -- Test routines
do
create sess.make ("http://www.google.com")
if attached sess.get ("/search?q=eiffel", Void) as res then
+ assert ("Get returned without error", not res.error_occurred)
create h.make_empty
if attached res.headers as hds then
across
@@ -32,7 +33,9 @@ feature -- Test routines
end
end
if attached res.body as l_body then
-
+ assert ("body not empty", not l_body.is_empty)
+ else
+ assert ("missing body", False)
end
assert ("same headers", h.same_string (res.raw_header))
else
@@ -67,20 +70,21 @@ feature -- Test routines
h.append (c.item.name + ": " + c.item.value + "%N")
end
end
- assert ("Expected headers map", h.same_string ("[
- normal: NORMAL
- concat: ABC
- concat: DEF
- key1: KEY
- key2: KEY
- key3: KEY
- value1: VALUE
- value2: VALUE
- value3: VALUE
- value4: VALUE
- foo: BAR
-
- ]"))
+ assert ("Expected headers map", h.same_string (
+"[
+normal: NORMAL
+concat: ABC
+concat: DEF
+key1: KEY
+key2: KEY
+key3: KEY
+value1: VALUE
+value2: VALUE
+value3: VALUE
+value4: VALUE
+foo: BAR
+
+]"))
end
end