[Index]

web:client


Execute an HTTP client request.

This is a very simple wrapper around Jetty's HTTPClient. Only PUT and GET requests are supported. Basic Authentication is supported, and so are SSL connections.


Property Summary

basicAuthentication Provide Username/Password for Basic Authentication.
content The request body to send or the response body received.
contentLength Content length of a response.
contentType The content-type of a POST request.
downloadCount The bytes downloaded so far.
method The request method.
name The name of the job.
output The output (such as a file) to download to.
parameters Parameters.
progress Progress of a download in a human-readable format.
requestBody The content to send in a POST Request.
responseBody The content received if an output is not provided.
ssl Provide SSL Configuration.
status The return status.
timeout Timeout of requests in seconds.
url The URL to connect to.

Example Summary

Example 1 Get the content of a URL using a parameter.
Example 2 Basic Authentication.
Example 3 Download to a file.

Property Detail

basicAuthentication

Configured ByELEMENT
AccessREAD_WRITE
RequiredNo.

Provide Username/Password for Basic Authentication.

content

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredNo.

The request body to send or the response body received. This maps to requestBody and responseBody as a convenience but is confusing so should probably be deprecated.

contentLength

AccessREAD_ONLY
RequiredRead only.

Content length of a response.

contentType

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredNo.

The content-type of a POST request. Useful for sending forms.

downloadCount

AccessREAD_ONLY
RequiredRead only.

The bytes downloaded so far. Only set for a stream download.

method

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredNo defaults to GET.

The request method. GET/POST. PUT and DELETE are not supported yet.

name

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredNo.

The name of the job. Can be any text.

output

Configured ByELEMENT
AccessREAD_WRITE
RequiredNo.

The output (such as a file) to download to.

parameters

Configured ByELEMENT
AccessREAD_WRITE
RequiredNo.

Parameters.

progress

AccessREAD_ONLY
RequiredRead only.

Progress of a download in a human-readable format. Only set for a stream download.

requestBody

Configured ByTEXT
AccessREAD_WRITE
RequiredNo.

The content to send in a POST Request.

responseBody

AccessREAD_ONLY
RequiredRead only.

The content received if an output is not provided.

ssl

Configured ByELEMENT
AccessREAD_WRITE
RequiredNo.

Provide SSL Configuration.

status

AccessREAD_ONLY
RequiredRead Only.

The return status.

timeout

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredNo.

Timeout of requests in seconds.

url

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredYes.

The URL to connect to. Must be a full URL, e.g. http://www.google.com


Examples

Example 1

Get the content of a URL using a parameter.

<oddjob>
    <job>
        <sequential>
            <jobs>
                <properties>
                    <values>
                        <value key="some.url" value="http://www.google.com/search"/>
                    </values>
                </properties>
                <web:client id="request" url="${some.url}" xmlns:web="oddjob:web">
                    <parameters>
                        <map>
                            <values>
                                <value key="q" value="gold fish"/>
                            </values>
                        </map>
                    </parameters>
                </web:client>
                <echo>${request.content}</echo>
            </jobs>
        </sequential>
    </job>
</oddjob>

Example 2

Basic Authentication.

<oddjob id="oddjob">
    <job>
        <web:client id="client" url="http://localhost:${server.port}" xmlns:web="oddjob:web">
            <basicAuthentication>
                <is username="alice" password="secret"/>
            </basicAuthentication>
        </web:client>
    </job>
</oddjob>

Example 3

Download to a file.

<oddjob>
    <job>
        <sequential>
            <jobs>
                <properties>
                    <values>
                        <value key="some.url" value="http://ipv4.download.thinkbroadband.com/1GB.zip"/>
                        <value key="some.file" value="download.zip"/>
                    </values>
                </properties>
                <web:client id="request" name="Download Example" url="${some.url}" xmlns:web="oddjob:web">
                    <output>
                        <file file="${some.file}"/>
                    </output>
                </web:client>
            </jobs>
        </sequential>
    </job>
</oddjob>


(c) R Gordon Ltd 2005 - Present