Package org.oddjob.jetty
Class JettyHttpClient
java.lang.Object
org.oddjob.jetty.JettyHttpClient
- Author:
- rob
Description
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.
Example
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>
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>
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>
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic class -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncall()longlonggetName()getSsl()intlonggetUrl()voidsetBasicAuthentication(JettyHttpClient.UsernamePassword basicAuthentication) voidsetContent(String content) voidsetContentType(String contentType) voidvoidvoidsetOutput(OutputStream output) voidsetParameters(Map<String, String> properties) voidsetRequestBody(String requestBody) voidsetSsl(ClientSslProvider ssl) voidsetTimeout(long timeout) voidtoString()
-
Field Details
-
DEFAULT_TIMEOUT_SECONDS
public static final int DEFAULT_TIMEOUT_SECONDS- See Also:
-
-
Constructor Details
-
JettyHttpClient
public JettyHttpClient()
-
-
Method Details
-
call
-
getName
-
setName
-
setUrl
-
getUrl
-
getStatus
public int getStatus() -
getContent
- Reference Property:
- content
- Required:
- No.
Description
The request body to send or the response body received. This maps torequestBody andresponseBodyas a convenience but is confusing so should probably be deprecated. -
setContent
-
getRequestBody
-
setRequestBody
-
getResponseBody
-
getMethod
-
setMethod
-
getParameters
-
setParameters
-
getContentType
-
setContentType
-
getBasicAuthentication
-
setBasicAuthentication
-
getSsl
-
setSsl
-
getProgress
-
getContentLength
public long getContentLength() -
getDownloadCount
public long getDownloadCount() -
getOutput
-
setOutput
-
getTimeout
public long getTimeout() -
setTimeout
public void setTimeout(long timeout) -
toString
-