本文整理汇总了Java中com.badlogic.gdx.Net.HttpRequest.setTimeOut方法的典型用法代码示例。如果您正苦于以下问题:Java HttpRequest.setTimeOut方法的具体用法?Java HttpRequest.setTimeOut怎么用?Java HttpRequest.setTimeOut使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.Net.HttpRequest
的用法示例。
在下文中一共展示了HttpRequest.setTimeOut方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: urlCheck
import com.badlogic.gdx.Net.HttpRequest; //导入方法依赖的package包/类
private void urlCheck(final String url, final LinkListener listener) {
HttpRequest request = new HttpRequest(HttpMethods.GET);
request.setUrl(url);
request.setTimeOut(TIMEOUT_MS);
Gdx.net.sendHttpRequest(request, new HttpResponseListener() {
@Override
public void handleHttpResponse(HttpResponse httpResponse) {
if (httpResponse.getStatus().getStatusCode() == HttpStatus.SC_OK) {
listener.ok(url);
} else {
listener.ko(url);
}
}
@Override
public void failed(Throwable t) {
listener.ko(url);
}
@Override
public void cancelled() {
listener.ko(url);
}
});
}
示例2: sendRequest
import com.badlogic.gdx.Net.HttpRequest; //导入方法依赖的package包/类
private void sendRequest(final TwitterRequest twitterRequest, final TwitterResponseListener listener) {
HttpRequestBuilder requestBuilder = new HttpRequestBuilder();
HttpRequest httpRequest = requestBuilder.newRequest().method(twitterRequest.getRequestType().name()).url(twitterRequest.getUrl()).build();
// System.out.println(twitterRequest.build().getHeader());
twitterRequest.build();
httpRequest.setHeader("Authorization", twitterRequest.getHeader());
httpRequest.setContent(twitterRequest.getData());
httpRequest.setTimeOut(config.TWITTER_REQUEST_TIMEOUT);
Gdx.net.sendHttpRequest(httpRequest, new HttpResponseListener() {
@Override
public void handleHttpResponse(HttpResponse httpResponse) {
if (httpResponse.getStatus().getStatusCode() == 200) {
listener.success(httpResponse.getResultAsString());
} else {
listener.apiError(httpResponse.getStatus(), httpResponse.getResultAsString());
}
}
@Override
public void failed(Throwable t) {
listener.httpError(t);
}
@Override
public void cancelled() {
listener.cancelled();
}
});
}
示例3: getTAPData
import com.badlogic.gdx.Net.HttpRequest; //导入方法依赖的package包/类
private String[][] getTAPData(String url, boolean hip, final String format, final GaiaDataListener listener) {
HttpRequest request = new HttpRequest(HttpMethods.GET);
request.setUrl(url);
request.setTimeOut(5000);
Gdx.net.sendHttpRequest(request, new HttpResponseListener() {
@Override
public void handleHttpResponse(HttpResponse httpResponse) {
if (httpResponse.getStatus().getStatusCode() == HttpStatus.SC_OK) {
// Ok
listener.ok(isToArray(httpResponse.getResultAsStream(), format), hip);
} else {
// Ko with code
listener.ko(httpResponse.getStatus().toString());
}
}
@Override
public void failed(Throwable t) {
// Failed
listener.ko();
}
@Override
public void cancelled() {
// Cancelled
listener.ko();
}
});
return null;
}
示例4: sendHttpGetRequest
import com.badlogic.gdx.Net.HttpRequest; //导入方法依赖的package包/类
@Override
public <T> T sendHttpGetRequest(String URL, Class<T> type)
throws IOException {
HttpRequest httpRequest = Pools.obtain(HttpRequest.class);
httpRequest.setMethod(Net.HttpMethods.GET);
httpRequest.setTimeOut(TIMEOUT);
httpRequest.setUrl(URL);
try {
return sendHttpRequest(httpRequest, type);
} finally {
Pools.free(httpRequest);
}
}