added remaining features

This commit is contained in:
Florian Jacky
2015-08-19 22:50:11 +02:00
committed by Jocelyn Fiat
parent eed8af9a0a
commit 0557d1ee2d
4 changed files with 258 additions and 25 deletions

View File

@@ -0,0 +1,137 @@
note
description : "httptest application root class"
date : "$Date$"
revision : "$Revision$"
class
APPLICATION
inherit
ARGUMENTS
create
make
feature {NONE} -- Initialization
make
-- Run application.
local
sess: NET_HTTP_CLIENT_SESSION
h: STRING_8
l_ctx: HTTP_CLIENT_REQUEST_CONTEXT
l_test_case: INTEGER
l_requestbin_path: STRING
do
l_requestbin_path := "/15u47xi2"
create h.make_empty
l_test_case := 1 -- select which test to execute
inspect l_test_case
when 1 then
-- URL ENCODED POST REQUEST
-- check requestbin to ensure the "Hello World" has been received in the raw body
-- also check that User-Agent was sent
create sess.make("http://requestb.in")
if attached sess.post (l_requestbin_path, Void, "Hello World").headers as hds then
across
hds as c
loop
h.append (c.item.name + ": " + c.item.value + "%R%N")
end
end
print (h)
when 2 then
-- POST REQUEST WITH FORM DATA
-- check requestbin to ensure the form parameters are correctly received
create sess.make("http://requestb.in")
create l_ctx.make
l_ctx.form_parameters.extend ("First Value", "First Key")
l_ctx.form_parameters.extend ("Second Value", "Second Key")
create sess.make("http://requestb.in")
if attached sess.post (l_requestbin_path, l_ctx, "").headers as hds then
across
hds as c
loop
h.append (c.item.name + ": " + c.item.value + "%R%N")
end
end
when 3 then
-- POST REQUEST WITH A FILE
-- check requestbin to ensure the form parameters are correctly received
-- set filename to a local file
create sess.make("http://requestb.in")
create l_ctx.make
l_ctx.set_upload_filename ("C:\temp\test.txt")
if attached sess.post (l_requestbin_path, l_ctx, "").headers as hds then
across
hds as c
loop
h.append (c.item.name + ": " + c.item.value + "%R%N")
end
end
when 4 then
-- PUT REQUEST WITH A FILE
-- check requestbin to ensure the file is correctly received
-- set filename to a local file
create sess.make("http://requestb.in")
create l_ctx.make
l_ctx.set_upload_filename ("C:\temp\test.txt")
if attached sess.put (l_requestbin_path, l_ctx, "").headers as hds then
across
hds as c
loop
h.append (c.item.name + ": " + c.item.value + "%R%N")
end
end
when 5 then
-- POST REQUEST WITH A FILE AND FORM DATA
-- check requestbin to ensure the file and form parameters are correctly received
-- set filename to a local file
create sess.make("http://requestb.in")
create l_ctx.make
l_ctx.set_upload_filename ("C:\temp\logo.png")
l_ctx.form_parameters.extend ("First Value", "First Key")
l_ctx.form_parameters.extend ("Second Value", "Second Key")
if attached sess.post (l_requestbin_path, l_ctx, "").headers as hds then
across
hds as c
loop
h.append (c.item.name + ": " + c.item.value + "%R%N")
end
end
when 6 then
-- GET REQUEST, Forwarding (google's first answer is a forward)
-- check headers received (printed in console)
create sess.make("http://google.com")
if attached sess.get ("/", Void).headers as hds then
across
hds as c
loop
h.append (c.item.name + ": " + c.item.value + "%R%N")
end
end
print (h)
when 7 then
-- GET REQUEST WITH AUTHENTICATION, see http://browserspy.dk/password.php
-- check header WWW-Authendicate is received (authentication successful)
create sess.make("http://test:test1@browserspy.dk")
if attached sess.get ("/password-ok.php", Void).headers as hds then
across
hds as c
loop
h.append (c.item.name + ": " + c.item.value + "%R%N")
end
end
print (h)
else
end
end
end

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-13-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-13-0 http://www.eiffel.com/developers/xml/configuration-1-13-0.xsd" name="httptest" uuid="C8DFC1BA-78CA-4518-B0F2-2241E42808FF">
<target name="httptest">
<root class="APPLICATION" feature="make"/>
<option warning="true" void_safety="none">
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
</option>
<setting name="console_application" value="true"/>
<precompile name="base_pre" location="$ISE_PRECOMP\base-safe.ecf"/>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="http_client" location="..\http_client-safe.ecf"/>
<cluster name="httptest" location=".\" recursive="true">
<file_rule>
<exclude>/EIFGENs$</exclude>
<exclude>/CVS$</exclude>
<exclude>/.svn$</exclude>
</file_rule>
</cluster>
</target>
</system>