|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.badlogic.gdx.Net.HttpRequest
public static class Net.HttpRequest
Contains getters and setters for the following parameters:
HttpMethods
for static
referencesMapparameters = new HashMap (); parameters.put("user", "myuser"); HttpRequest httpGet = new HttpRequest(HttpMethods.Get); httpGet.setUrl("http://somewhere.net"); httpGet.setContent(HttpParametersUtils.convertHttpParameters(parameters)); ... Gdx.net.sendHttpRequest (httpGet, new HttpResponseListener() { public void handleHttpResponse(HttpResponse httpResponse) { status = httpResponse.getResultAsString(); //do stuff here based on response } public void failed(Throwable t) { status = "failed"; //do stuff here based on the failed attempt } });
Constructor Summary | |
---|---|
Net.HttpRequest(String httpMethod)
Creates a new HTTP request with the specified HTTP method, see Net.HttpMethods . |
Method Summary | |
---|---|
String |
getContent()
Returns the content string to be used for the HTTP request. |
long |
getContentLength()
Returns the content length in case content is a stream. |
InputStream |
getContentStream()
Returns the content stream. |
Map<String,String> |
getHeaders()
Returns a Map |
String |
getMethod()
Returns the HTTP method of the HttpRequest. |
int |
getTimeOut()
Returns the timeOut of the HTTP request. |
String |
getUrl()
Returns the URL of the HTTP request. |
void |
setContent(InputStream contentStream,
long contentLength)
Sets the content as a stream to be used for a POST for example, to transmit custom data. |
void |
setContent(String content)
Sets the content to be used in the HTTP request. |
void |
setHeader(String name,
String value)
Sets a header to this HTTP request. |
void |
setTimeOut(int timeOut)
Sets the time to wait for the HTTP request to be processed, use 0 block until it is done. |
void |
setUrl(String url)
Sets the URL of the HTTP request. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Net.HttpRequest(String httpMethod)
Net.HttpMethods
.
httpMethod
- This is the HTTP method for the request, see Net.HttpMethods
Method Detail |
---|
public void setUrl(String url)
url
- The URL to set.public void setHeader(String name, String value)
name
- the name of the header.value
- the value of the header.public void setContent(String content)
content
- A string encoded in the corresponding Content-Encoding set in the headers, with the data to send with the
HTTP request. For example, in case of HTTP GET, the content is used as the query string of the GET while on a
HTTP POST it is used to send the POST data.public void setContent(InputStream contentStream, long contentLength)
contentStream
- The stream with the content data.public void setTimeOut(int timeOut)
timeOut
- the number of milliseconds to wait before giving up, 0 or negative to block until the operation is donepublic int getTimeOut()
public String getMethod()
public String getUrl()
public String getContent()
public InputStream getContentStream()
public long getContentLength()
public Map<String,String> getHeaders()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |