Files
EWF/library/client/http_client/tests/test_http_client.e
unknown 497fe03d38 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.
2012-02-08 21:32:25 +01:00

93 lines
1.8 KiB
Plaintext

note
description: "[
Eiffel tests that can be executed by testing tool.
]"
author: "EiffelStudio test wizard"
date: "$Date$"
revision: "$Revision$"
testing: "type/manual"
class
TEST_HTTP_CLIENT
inherit
EQA_TEST_SET
feature -- Test routines
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)
else
assert ("missing body", False)
end
assert ("same headers", h.same_string (res.raw_header))
else
assert ("Not found", False)
end
end
test_headers
local
res: HTTP_CLIENT_RESPONSE
h: STRING
do
create res.make
create h.make_empty
h.append ("normal: NORMAL%R%N")
h.append ("concat: ABC%R%N")
h.append ("concat: DEF%R%N")
h.append ("key1: KEY%R%N")
h.append (" key2 : KEY%R%N")
h.append (" %T key3 : KEY%R%N")
h.append ("value1:VALUE%R%N")
h.append ("value2: VALUE%R%N")
h.append ("value3: VALUE%R%N")
h.append ("value4: VALUE %R%N")
h.append (" %Tfoo : BAR%T %R%N")
res.set_raw_header (h)
create h.make_empty
if attached res.headers as hds then
across
hds as c
loop
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
]"))
end
end