本文整理汇总了Java中com.koushikdutta.async.http.AsyncHttpRequest类的典型用法代码示例。如果您正苦于以下问题:Java AsyncHttpRequest类的具体用法?Java AsyncHttpRequest怎么用?Java AsyncHttpRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AsyncHttpRequest类属于com.koushikdutta.async.http包,在下文中一共展示了AsyncHttpRequest类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: send
import com.koushikdutta.async.http.AsyncHttpRequest; //导入依赖的package包/类
@Override
public void send(String message) {
if (message.startsWith("5")) {
postMessage(message);
return;
}
AsyncHttpRequest request = new AsyncHttpPost(computedRequestUrl());
request.setBody(new StringBody(message));
client.executeString(request, new AsyncHttpClient.StringCallback() {
@Override
public void onCompleted(Exception e, AsyncHttpResponse source, String result) {
if (e != null) {
close(e);
return;
}
sendResult(result);
}
});
}
开发者ID:jacklongway,项目名称:LiteSDK,代码行数:23,代码来源:XHRPollingTransport.java
示例2: Entry
import com.koushikdutta.async.http.AsyncHttpRequest; //导入依赖的package包/类
public Entry(Uri uri, RawHeaders varyHeaders, AsyncHttpRequest request, RawHeaders responseHeaders) {
this.uri = uri.toString();
this.varyHeaders = varyHeaders;
this.requestMethod = request.getMethod();
this.responseHeaders = responseHeaders;
// if (isHttps()) {
// HttpsURLConnection httpsConnection = (HttpsURLConnection) httpConnection;
// cipherSuite = httpsConnection.getCipherSuite();
// Certificate[] peerCertificatesNonFinal = null;
// try {
// peerCertificatesNonFinal = httpsConnection.getServerCertificates();
// } catch (SSLPeerUnverifiedException ignored) {
// }
// peerCertificates = peerCertificatesNonFinal;
// localCertificates = httpsConnection.getLocalCertificates();
// } else {
cipherSuite = null;
peerCertificates = null;
localCertificates = null;
// }
}
开发者ID:jacklongway,项目名称:LiteSDK,代码行数:23,代码来源:ResponseCacheMiddleware.java
示例3: addHead
import com.koushikdutta.async.http.AsyncHttpRequest; //导入依赖的package包/类
private static void addHead(HashMap<String, String> header, AsyncHttpRequest asyncHttp) {
if (header != null && !header.isEmpty()) {
if (BuildConfig.DEBUG) {
LogUtils.d(header.toString());
}
Set<String> keys = header.keySet();
for (String key : keys) {
asyncHttp.setHeader(key, header.get(key));
}
}
}
开发者ID:jacklongway,项目名称:LiteSDK,代码行数:12,代码来源:HttpApi.java
示例4: postMessage
import com.koushikdutta.async.http.AsyncHttpRequest; //导入依赖的package包/类
private void postMessage(String message) {
if (!message.startsWith("5"))
return;
AsyncHttpRequest request = new AsyncHttpPost(computedRequestUrl());
request.setBody(new StringBody(message));
client.executeString(request, null);
}
开发者ID:jacklongway,项目名称:LiteSDK,代码行数:9,代码来源:XHRPollingTransport.java
示例5: write
import com.koushikdutta.async.http.AsyncHttpRequest; //导入依赖的package包/类
@Override
public void write(final AsyncHttpRequest request, final DataSink sink, final CompletedCallback completed) {
AsyncServer.getDefault().postDelayed(new Runnable() {
@Override
public void run() {
DelayedStringBody.super.write(request, sink, completed);
}
}, 1000);
}
开发者ID:jacklongway,项目名称:LiteSDK,代码行数:10,代码来源:TimeoutTests.java
示例6: listAllPeers
import com.koushikdutta.async.http.AsyncHttpRequest; //导入依赖的package包/类
/**
* Retrieves the list of peer that can be connected.
* @param callback Callback to return the list of peer
*/
public void listAllPeers(final OnAllPeersCallback callback) {
Uri uri = Uri.parse(createDiscoveryUrl());
AsyncHttpRequest req = new AsyncHttpRequest(uri, "GET");
addConfig(req);
AsyncHttpClient client = AsyncHttpClient.getDefaultInstance();
client.executeJSONArray(req, new AsyncHttpClient.JSONArrayCallback() {
@Override
public void onCompleted(final Exception e, final AsyncHttpResponse source, final JSONArray result) {
if (e != null) {
if (callback != null) {
callback.onErrorCallback();
}
} else {
int statusCode = source.code();
if (statusCode == 200) {
if (callback != null) {
callback.onCallback(result);
}
} else {
if (callback != null) {
callback.onErrorCallback();
}
}
}
}
});
}
开发者ID:DeviceConnect,项目名称:DeviceConnect-Android,代码行数:33,代码来源:SignalingClient.java
示例7: write
import com.koushikdutta.async.http.AsyncHttpRequest; //导入依赖的package包/类
@Override
public void write(AsyncHttpRequest request, final DataSink sink, final CompletedCallback completed) {
if (mParts == null)
return;
Continuation c = new Continuation(new CompletedCallback() {
@Override
public void onCompleted(Exception ex) {
completed.onCompleted(ex);
// if (ex == null)
// sink.end();
// else
// sink.close();
}
});
for (final Part part: mParts) {
c.add(new ContinuationCallback() {
@Override
public void onContinue(Continuation continuation, CompletedCallback next) throws Exception {
byte[] bytes = part.getRawHeaders().toPrefixString(getBoundaryStart()).getBytes();
com.koushikdutta.async.Util.writeAll(sink, bytes, next);
written += bytes.length;
}
})
.add(new ContinuationCallback() {
@Override
public void onContinue(Continuation continuation, CompletedCallback next) throws Exception {
long partLength = part.length();
if (partLength >= 0)
written += partLength;
part.write(sink, next);
}
})
.add(new ContinuationCallback() {
@Override
public void onContinue(Continuation continuation, CompletedCallback next) throws Exception {
byte[] bytes = "\r\n".getBytes();
com.koushikdutta.async.Util.writeAll(sink, bytes, next);
written += bytes.length;
}
});
}
c.add(new ContinuationCallback() {
@Override
public void onContinue(Continuation continuation, CompletedCallback next) throws Exception {
byte[] bytes = (getBoundaryEnd()).getBytes();
com.koushikdutta.async.Util.writeAll(sink, bytes, next);
written += bytes.length;
assert written == totalToWrite;
}
});
c.start();
}
开发者ID:jacklongway,项目名称:LiteSDK,代码行数:56,代码来源:MultipartFormDataBody.java
示例8: write
import com.koushikdutta.async.http.AsyncHttpRequest; //导入依赖的package包/类
@Override
public void write(AsyncHttpRequest request, DataSink sink, CompletedCallback completed) {
Util.pump(file, sink, completed);
}
开发者ID:jacklongway,项目名称:LiteSDK,代码行数:5,代码来源:FileBody.java
示例9: write
import com.koushikdutta.async.http.AsyncHttpRequest; //导入依赖的package包/类
@Override
public void write(AsyncHttpRequest request, DataSink sink, final CompletedCallback completed) {
if (mBodyBytes == null)
mBodyBytes = string.getBytes();
Util.writeAll(sink, mBodyBytes, completed);
}
开发者ID:jacklongway,项目名称:LiteSDK,代码行数:7,代码来源:StringBody.java
示例10: write
import com.koushikdutta.async.http.AsyncHttpRequest; //导入依赖的package包/类
@Override
public void write(AsyncHttpRequest request, DataSink sink, CompletedCallback completed) {
Util.pump(stream, length < 0 ? Integer.MAX_VALUE : length, sink, completed);
}
开发者ID:jacklongway,项目名称:LiteSDK,代码行数:5,代码来源:StreamBody.java
示例11: write
import com.koushikdutta.async.http.AsyncHttpRequest; //导入依赖的package包/类
@Override
public void write(AsyncHttpRequest request, DataSink sink, final CompletedCallback completed) {
Util.writeAll(sink, mBodyBytes, completed);
}
开发者ID:jacklongway,项目名称:LiteSDK,代码行数:5,代码来源:JSONArrayBody.java
示例12: write
import com.koushikdutta.async.http.AsyncHttpRequest; //导入依赖的package包/类
@Override
public void write(AsyncHttpRequest request, DataSink sink, CompletedCallback completed) {
prepare();
byte[] bytes = bout.toByteArray();
Util.writeAll(sink, bytes, completed);
}
开发者ID:jacklongway,项目名称:LiteSDK,代码行数:7,代码来源:DocumentBody.java
示例13: write
import com.koushikdutta.async.http.AsyncHttpRequest; //导入依赖的package包/类
@Override
public void write(AsyncHttpRequest request, final DataSink response, final CompletedCallback completed) {
if (mBodyBytes == null)
buildData();
Util.writeAll(response, mBodyBytes, completed);
}
开发者ID:jacklongway,项目名称:LiteSDK,代码行数:7,代码来源:UrlEncodedFormBody.java
示例14: newSocket
import com.koushikdutta.async.http.AsyncHttpRequest; //导入依赖的package包/类
private void newSocket(GetSocketData data, final AsyncSpdyConnection connection, final ConnectCallback callback) {
final AsyncHttpRequest request = data.request;
data.protocol = connection.protocol.toString();
final AsyncHttpRequestBody requestBody = data.request.getBody();
// this causes app engine to shit a brick, but if it is missing,
// drive shits the bed
// if (requestBody != null) {
// if (requestBody.length() >= 0) {
// request.getHeaders().set("Content-Length", String.valueOf(requestBody.length()));
// }
// }
final ArrayList<Header> headers = new ArrayList<Header>();
headers.add(new Header(Header.TARGET_METHOD, request.getMethod()));
headers.add(new Header(Header.TARGET_PATH, requestPath(request.getUri())));
String host = request.getHeaders().get("Host");
if (Protocol.SPDY_3 == connection.protocol) {
headers.add(new Header(Header.VERSION, "HTTP/1.1"));
headers.add(new Header(Header.TARGET_HOST, host));
} else if (Protocol.HTTP_2 == connection.protocol) {
headers.add(new Header(Header.TARGET_AUTHORITY, host)); // Optional in HTTP/2
} else {
throw new AssertionError();
}
headers.add(new Header(Header.TARGET_SCHEME, request.getUri().getScheme()));
final Multimap mm = request.getHeaders().getMultiMap();
for (String key: mm.keySet()) {
if (SpdyTransport.isProhibitedHeader(connection.protocol, key))
continue;
for (String value: mm.get(key)) {
headers.add(new Header(key.toLowerCase(), value));
}
}
request.logv("\n" + request);
final AsyncSpdyConnection.SpdySocket spdy = connection.newStream(headers, requestBody != null, true);
callback.onConnectCompleted(null, spdy);
}
开发者ID:jacklongway,项目名称:LiteSDK,代码行数:43,代码来源:SpdyMiddleware.java
示例15: write
import com.koushikdutta.async.http.AsyncHttpRequest; //导入依赖的package包/类
@Override
public void write(final AsyncHttpRequest request, DataSink sink, final CompletedCallback completed) {
Util.pump(emitter, sink, completed);
if (emitter.isPaused())
emitter.resume();
}
开发者ID:jacklongway,项目名称:LiteSDK,代码行数:7,代码来源:UnknownRequestBody.java
示例16: testUriPathWithSpaces
import com.koushikdutta.async.http.AsyncHttpRequest; //导入依赖的package包/类
public void testUriPathWithSpaces() throws Exception {
AsyncHttpRequest request = new AsyncHttpRequest(Uri.parse("http://jpkc.seiee.sjtu.edu.cn/ds/ds2/Course%20lecture/chapter%2010.pdf"), AsyncHttpGet.METHOD);
String requestLine = request.getRequestLine().toString();
assertEquals("GET /ds/ds2/Course%20lecture/chapter%2010.pdf HTTP/1.1", requestLine);
}
开发者ID:jacklongway,项目名称:LiteSDK,代码行数:6,代码来源:HttpClientTests.java
注:本文中的com.koushikdutta.async.http.AsyncHttpRequest类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论