当前位置: 首页>>代码示例>>Java>>正文


Java HttpResponse类代码示例

本文整理汇总了Java中com.mpush.api.http.HttpResponse的典型用法代码示例。如果您正苦于以下问题:Java HttpResponse类的具体用法?Java HttpResponse怎么用?Java HttpResponse使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


HttpResponse类属于com.mpush.api.http包,在下文中一共展示了HttpResponse类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sendHttpProxy

import com.mpush.api.http.HttpResponse; //导入依赖的package包/类
/**
 * 发送Http代理请求
 *
 * @param request 要代理的http请求
 * @return
 */
public Future<HttpResponse> sendHttpProxy(HttpRequest request) {
    if (hasStarted() && client.isRunning()) {
        return client.sendHttp(request);
    }
    return null;
}
 
开发者ID:stulip,项目名称:react-native-mpush,代码行数:13,代码来源:MPush.java

示例2: handle

import com.mpush.api.http.HttpResponse; //导入依赖的package包/类
@Override
public void handle(HttpResponseMessage message) {
    HttpRequestMgr.RequestTask task = httpRequestMgr.getAndRemove(message.getSessionId());
    if (task != null) {
        HttpResponse response = new HttpResponse(message.statusCode, message.reasonPhrase, message.headers, message.body);
        task.setResponse(response);
    }
    logger.d(">>> receive one response, sessionId=%d, statusCode=%d", message.getSessionId(), message.statusCode);
}
 
开发者ID:mpusher,项目名称:mpush-client-java,代码行数:10,代码来源:HttpProxyHandler.java

示例3: sendHttp

import com.mpush.api.http.HttpResponse; //导入依赖的package包/类
@Override
public Future<HttpResponse> sendHttp(HttpRequest request) {
    if (connection.getSessionContext().handshakeOk()) {
        HttpRequestMessage message = new HttpRequestMessage(connection);
        message.method = request.getMethod();
        message.uri = request.getUri();
        message.headers = request.getHeaders();
        message.body = request.getBody();
        message.send();
        logger.d("<<< send http proxy, request=%s", request);
        return httpRequestMgr.add(message.getSessionId(), request);
    }
    return null;
}
 
开发者ID:mpusher,项目名称:mpush-client-java,代码行数:15,代码来源:MPushClient.java

示例4: setResponse

import com.mpush.api.http.HttpResponse; //导入依赖的package包/类
public void setResponse(HttpResponse response) {
    if (this.future.cancel(true)) {
        this.set(response);
        if (callback != null) {
            callback.onResponse(response);
        }
        callback = null;
    }
    logger.d("one request task end, sessionId=%d, costTime=%d, response=%d, uri=%s",
            sessionId, (System.currentTimeMillis() - sendTime), response.statusCode, uri);
}
 
开发者ID:mpusher,项目名称:mpush-client-java,代码行数:12,代码来源:HttpRequestMgr.java

示例5: sendPush

import com.mpush.api.http.HttpResponse; //导入依赖的package包/类
@ReactMethod
public void sendPush(final ReadableMap options, final Promise promise){
    if( !MPush.I.hasInit()) {
        promise.reject("MPush is not init!");
        return;
    }
    if( !options.hasKey("userId")) {
        promise.reject("Params userId is null!");
        return;
    }
    if( !options.hasKey("hello")) {
        promise.reject("Params hello is null!");
        return;
    }

    final Activity activity = getCurrentActivity();
    if (activity == null) {
        promise.reject("Current Activity is null!");
        return;
    }

    JSONObject params = new JSONObject();
    try {
        params.put("userId", options.getString("userId"));
        params.put("hello", options.getString("hello"));
    } catch (JSONException e) {
        promise.reject("SendPush For Exception: " + e.getMessage());
        return;
    }

    final Context context = getReactApplicationContext();
    HttpRequest request = new HttpRequest(HttpMethod.POST, allocServer + "/push");
    byte[] body = params.toString().getBytes(Constants.UTF_8);
    request.setBody(body, "application/json; charset=utf-8");
    request.setTimeout((int) TimeUnit.SECONDS.toMillis(10));
    request.setCallback(new HttpCallback() {
        @Override
        public void onResponse(final HttpResponse httpResponse) {
            activity.runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    if (httpResponse.statusCode == 200) {
                        promise.resolve(new String(httpResponse.body, Constants.UTF_8));
                    } else {
                        promise.reject(httpResponse.reasonPhrase);
                    }
                }
            });
        }

        @Override
        public void onCancelled() {
            promise.reject("SendPush on cancelled");
        }
    });
    MPush.I.sendHttpProxy(request);
}
 
开发者ID:stulip,项目名称:react-native-mpush,代码行数:58,代码来源:RCTMPushModule.java

示例6: call

import com.mpush.api.http.HttpResponse; //导入依赖的package包/类
@Override
public HttpResponse call() throws Exception {
    return response408;
}
 
开发者ID:mpusher,项目名称:mpush-client-java,代码行数:5,代码来源:HttpRequestMgr.java

示例7: add

import com.mpush.api.http.HttpResponse; //导入依赖的package包/类
public Future<HttpResponse> add(int sessionId, HttpRequest request) {
    RequestTask task = new RequestTask(sessionId, request);
    queue.put(sessionId, task);
    task.future = timer.schedule(task, task.timeout, TimeUnit.MILLISECONDS);
    return task;
}
 
开发者ID:mpusher,项目名称:mpush-client-java,代码行数:7,代码来源:HttpRequestMgr.java

示例8: sendHttp

import com.mpush.api.http.HttpResponse; //导入依赖的package包/类
Future<HttpResponse> sendHttp(HttpRequest request); 
开发者ID:mpusher,项目名称:mpush-client-java,代码行数:2,代码来源:MPushProtocol.java


注:本文中的com.mpush.api.http.HttpResponse类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。