libcurl: Applied a workaround to avoid issue on Win32 (see LIBCURL_HTTP_CLIENT_REQUEST.apply_workaround)

Separated the http_client-safe.ecf and test-safe.ecf
Added HTTP_CLIENT_SESSION.set_max_redirects
Fixed broken test due to formatting trouble.
This commit is contained in:
unknown
2012-02-08 21:32:25 +01:00
parent ca3a520bb9
commit 497fe03d38
7 changed files with 128 additions and 42 deletions

View File

@@ -10,6 +10,7 @@
<option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all" syntax="provisional"> <option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all" syntax="provisional">
</option> </option>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/> <library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="net" location="$ISE_LIBRARY\library\net\net-safe.ecf"/>
<library name="curl" location="$ISE_LIBRARY\library\cURL\cURL-safe.ecf"> <library name="curl" location="$ISE_LIBRARY\library\cURL\cURL-safe.ecf">
<condition> <condition>
<version type="compiler" min="7.0.8.7340"/> <version type="compiler" min="7.0.8.7340"/>
@@ -23,17 +24,4 @@
<library name="encoder" location="..\..\text\encoder\encoder-safe.ecf"/> <library name="encoder" location="..\..\text\encoder\encoder-safe.ecf"/>
<cluster name="src" location=".\src\" recursive="true"/> <cluster name="src" location=".\src\" recursive="true"/>
</target> </target>
<target name="tests" extends="http_client">
<root class="ANY" feature="default_create"/>
<file_rule>
<exclude>/.git$</exclude>
<exclude>/EIFGENs$</exclude>
<exclude>/.svn$</exclude>
</file_rule>
<option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all" syntax="provisional">
<assertions precondition="true"/>
</option>
<library name="testing" location="$ISE_LIBRARY\library\testing\testing-safe.ecf"/>
<tests name="tests" location=".\tests\"/>
</target>
</system> </system>

View File

@@ -10,6 +10,7 @@
<option warning="true" full_class_checking="true" void_safety="none" syntax="provisional"> <option warning="true" full_class_checking="true" void_safety="none" syntax="provisional">
</option> </option>
<library name="base" location="$ISE_LIBRARY/library/base/base.ecf"/> <library name="base" location="$ISE_LIBRARY/library/base/base.ecf"/>
<library name="net" location="$ISE_LIBRARY\library\net\net.ecf"/>
<library name="curl" location="$ISE_LIBRARY\library\cURL\cURL.ecf"> <library name="curl" location="$ISE_LIBRARY\library\cURL\cURL.ecf">
<condition> <condition>
<version type="compiler" min="7.0.8.7340"/> <version type="compiler" min="7.0.8.7340"/>

View File

@@ -1,12 +1,29 @@
note note
description : "Objects that ..." description : "[
author : "$Author$" HTTP_CLIENT_SESSION represent a session
date : "$Date$" and is used to call get, post, .... request
revision : "$Revision$" with predefined settings such as
base_url
specific common headers
timeout and so on ...
]"
author: "$Author$"
date: "$Date$"
revision: "$Revision$"
deferred class deferred class
HTTP_CLIENT_SESSION 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 feature {NONE} -- Initialization
make (a_base_url: READABLE_STRING_8) make (a_base_url: READABLE_STRING_8)
@@ -154,37 +171,36 @@ feature -- Change
set_auth_type (s: READABLE_STRING_8) set_auth_type (s: READABLE_STRING_8)
do do
auth_type := s auth_type := s
auth_type_id := http_client_constants.auth_type_id (s) auth_type_id := auth_type_id_from_string (s)
end end
set_basic_auth_type set_basic_auth_type
do do
auth_type := "basic" auth_type := "basic"
auth_type_id := {HTTP_CLIENT_CONSTANTS}.auth_type_basic auth_type_id := Auth_type_basic
end end
set_digest_auth_type set_digest_auth_type
do do
auth_type := "digest" auth_type := "digest"
auth_type_id := {HTTP_CLIENT_CONSTANTS}.auth_type_digest auth_type_id := Auth_type_digest
end end
set_any_auth_type set_any_auth_type
do do
auth_type := "any" auth_type := "any"
auth_type_id := {HTTP_CLIENT_CONSTANTS}.auth_type_any auth_type_id := Auth_type_any
end end
set_anysafe_auth_type set_anysafe_auth_type
do do
auth_type := "anysafe" auth_type := "anysafe"
auth_type_id := {HTTP_CLIENT_CONSTANTS}.auth_type_anysafe auth_type_id := Auth_type_anysafe
end end
feature {NONE} -- Implementation set_max_redirects (n: like max_redirects)
do
http_client_constants: HTTP_CLIENT_CONSTANTS max_redirects := n
once
create Result
end end
end end

View File

@@ -24,6 +24,15 @@ feature {NONE} -- Initialization
do do
make_request (a_url, a_session, ctx) make_request (a_url, a_session, ctx)
request_method := a_request_method 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 end
session: LIBCURL_HTTP_CLIENT_SESSION session: LIBCURL_HTTP_CLIENT_SESSION

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-9-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-9-0 http://www.eiffel.com/developers/xml/configuration-1-9-0.xsd" name="test_http_client" uuid="920E5C50-41E1-4DAC-8D48-D9C860E49228">
<target name="test_http_client">
<root class="TEST" feature="make"/>
<file_rule>
<exclude>/.git$</exclude>
<exclude>/EIFGENs$</exclude>
<exclude>/.svn$</exclude>
</file_rule>
<option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all">
<assertions precondition="true"/>
</option>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="http_client" location="..\http_client-safe.ecf" readonly="false"/>
<library name="testing" location="$ISE_LIBRARY\library\testing\testing-safe.ecf"/>
<tests name="tests" location=".\"/>
</target>
</system>

View File

@@ -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

View File

@@ -23,6 +23,7 @@ feature -- Test routines
do do
create sess.make ("http://www.google.com") create sess.make ("http://www.google.com")
if attached sess.get ("/search?q=eiffel", Void) as res then if attached sess.get ("/search?q=eiffel", Void) as res then
assert ("Get returned without error", not res.error_occurred)
create h.make_empty create h.make_empty
if attached res.headers as hds then if attached res.headers as hds then
across across
@@ -32,7 +33,9 @@ feature -- Test routines
end end
end end
if attached res.body as l_body then if attached res.body as l_body then
assert ("body not empty", not l_body.is_empty)
else
assert ("missing body", False)
end end
assert ("same headers", h.same_string (res.raw_header)) assert ("same headers", h.same_string (res.raw_header))
else else
@@ -67,20 +70,21 @@ feature -- Test routines
h.append (c.item.name + ": " + c.item.value + "%N") h.append (c.item.name + ": " + c.item.value + "%N")
end end
end end
assert ("Expected headers map", h.same_string ("[ assert ("Expected headers map", h.same_string (
normal: NORMAL "[
concat: ABC normal: NORMAL
concat: DEF concat: ABC
key1: KEY concat: DEF
key2: KEY key1: KEY
key3: KEY key2: KEY
value1: VALUE key3: KEY
value2: VALUE value1: VALUE
value3: VALUE value2: VALUE
value4: VALUE value3: VALUE
foo: BAR value4: VALUE
foo: BAR
]")) ]"))
end end
end end