Top Description Fields Constructors Methods
org.apache.tools.ant.taskdefs.condition

public Class Http

extends ProjectComponent
implements Condition
Class Inheritance
All Implemented Interfaces
org.apache.tools.ant.taskdefs.condition.Condition
Imports
java.io.IOException, java.net.HttpURLConnection, .MalformedURLException, .ProtocolException, .URL, .URLConnection, java.util.Locale, org.apache.tools.ant.BuildException, .Project, .ProjectComponent, org.apache.tools.ant.taskdefs.Get

Condition to wait for a HTTP request to succeed. Its attribute(s) are: url - the URL of the request. errorsBeginAt - number at which errors begin at; default=400. requestMethod - HTTP request method to use; GET, HEAD, etc. default=GET readTimeout - The read timeout in ms. default=0
Since
Ant 1.5

Field Summary

Modifier and TypeField and Description
private static final String
private static final int
private int
private boolean
private static final String
private static final String
private int
private String
private String
Inherited from org.apache.tools.ant.ProjectComponent:
descriptionlocationproject

Constructor Summary

AccessConstructor and Description
public
Http()

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the HTTP request succeeds
eval
()

Implements org.apache.tools.ant.taskdefs.condition.Condition.eval.

Is this condition true?
private boolean
redirectionAllowed(final URL from, final URL to)

private int
request(final HttpURLConnection http, final URL url)

public void
setErrorsBeginAt(int
number at which errors begin at, default is 400
errorsBeginAt
)

Set the errorsBeginAt attribute

public void
setFollowRedirects(boolean
boolean
f
)

Whether redirects sent by the server should be followed, defaults to true.

public void
setReadTimeout(int
the timeout value in milli seconds
t
)

Sets the read timeout.

public void
setRequestMethod(String
The HTTP request method to use. Valid values are the same as those accepted by the HttpURLConnection.setRequestMethod() method, such as "GET", "HEAD", "TRACE", etc. The default if not specified is "GET".
method
)

Sets the method to be used when issuing the HTTP request.

public void
setUrl(String
the url of the request
url
)

Set the url attribute

Inherited from org.apache.tools.ant.ProjectComponent:
clonegetDescriptiongetLocationgetProjectloglogsetDescriptionsetLocationsetProject

Field Detail

DEFAULT_REQUEST_METHODback to summary
private static final String DEFAULT_REQUEST_METHOD
ERROR_BEGINSback to summary
private static final int ERROR_BEGINS
errorsBeginAtback to summary
private int errorsBeginAt
followRedirectsback to summary
private boolean followRedirects
HTTPback to summary
private static final String HTTP
HTTPSback to summary
private static final String HTTPS
readTimeoutback to summary
private int readTimeout
requestMethodback to summary
private String requestMethod
specback to summary
private String spec

Constructor Detail

Httpback to summary
public Http()

Method Detail

evalback to summary
public boolean eval() throws BuildException

Implements org.apache.tools.ant.taskdefs.condition.Condition.eval.

Doc from org.apache.tools.ant.taskdefs.condition.Condition.eval.

Is this condition true?

Returns:boolean

true if the HTTP request succeeds

Annotations
@Override
Exceptions
BuildException:
if an error occurs
redirectionAllowedback to summary
private boolean redirectionAllowed(final URL from, final URL to)
requestback to summary
private int request(final HttpURLConnection http, final URL url) throws IOException
setErrorsBeginAtback to summary
public void setErrorsBeginAt(int errorsBeginAt)

Set the errorsBeginAt attribute

Parameters
errorsBeginAt:int

number at which errors begin at, default is 400

setFollowRedirectsback to summary
public void setFollowRedirects(boolean f)

Whether redirects sent by the server should be followed, defaults to true.

Parameters
f:boolean

boolean

Since
Ant 1.9.7
setReadTimeoutback to summary
public void setReadTimeout(int t)

Sets the read timeout. Any value < 0 will be ignored

Parameters
t:int

the timeout value in milli seconds

Since
Ant 1.10.6
See Also
java.net.HttpURLConnection#setReadTimeout
setRequestMethodback to summary
public void setRequestMethod(String method)

Sets the method to be used when issuing the HTTP request.

Parameters
method:String

The HTTP request method to use. Valid values are the same as those accepted by the HttpURLConnection.setRequestMethod() method, such as "GET", "HEAD", "TRACE", etc. The default if not specified is "GET".

Since
Ant 1.8.0
See Also
java.net.HttpURLConnection#setRequestMethod
setUrlback to summary
public void setUrl(String url)

Set the url attribute

Parameters
url:String

the url of the request