Added https support with Net implementation.
Added notion of default HTTP_CLIENT, to be able to build portable code among http client implementation.
This commit is contained in:
@@ -13,16 +13,40 @@ feature -- Init
|
||||
if attached null.new_session ("http://example.com/") as l_sess then
|
||||
check not l_sess.is_available end
|
||||
end
|
||||
test_get_with_authentication
|
||||
test_http_client
|
||||
end
|
||||
|
||||
test_get_with_authentication
|
||||
local
|
||||
cl: DEFAULT_HTTP_CLIENT
|
||||
sess: HTTP_CLIENT_SESSION
|
||||
ctx: HTTP_CLIENT_REQUEST_CONTEXT
|
||||
do
|
||||
-- GET REQUEST WITH AUTHENTICATION, see http://browserspy.dk/password.php
|
||||
-- check header WWW-Authenticate is received (authentication successful)
|
||||
create cl
|
||||
sess := cl.new_session ("http://browserspy.dk")
|
||||
sess.set_credentials ("test", "test")
|
||||
create ctx.make_with_credentials_required
|
||||
if attached sess.get ("/password-ok.php", ctx) as res then
|
||||
if attached {READABLE_STRING_8} res.body as l_body then
|
||||
assert ("Fetch all body, including closing html tag", l_body.has_substring ("</html>"))
|
||||
else
|
||||
assert ("has body", False)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
test_http_client
|
||||
-- New test routine
|
||||
local
|
||||
sess: LIBCURL_HTTP_CLIENT_SESSION
|
||||
cl: DEFAULT_HTTP_CLIENT
|
||||
sess: HTTP_CLIENT_SESSION
|
||||
h: STRING_8
|
||||
do
|
||||
create sess.make ("http://www.google.com")
|
||||
create cl
|
||||
sess := cl.new_session ("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
|
||||
|
||||
Reference in New Issue
Block a user