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


Java HttpClientResponse.statusCode方法代码示例

本文整理汇总了Java中org.vertx.java.core.http.HttpClientResponse.statusCode方法的典型用法代码示例。如果您正苦于以下问题:Java HttpClientResponse.statusCode方法的具体用法?Java HttpClientResponse.statusCode怎么用?Java HttpClientResponse.statusCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.vertx.java.core.http.HttpClientResponse的用法示例。


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

示例1: handleFailure

import org.vertx.java.core.http.HttpClientResponse; //导入方法依赖的package包/类
private void handleFailure(
        final HttpConnection connection,
        final HttpClientResponse response,
        final Handler<Boolean> handler) {

    if (response.statusCode() < HTTP_SUCCESS_CODE
            || response.statusCode() >= HTTP_REDIRECTION_CODE) {

        connection.disconnect();
        if (handler != null) {
            handler.handle(FALSE);
        }
        m_logger.error("Ignoring host: {}",
                connection.getAddress(),
                new IllegalStateException("Connection failure: "
                        + response.statusCode()
                        + "/"
                        + response.statusMessage()));
    }
}
 
开发者ID:clidev,项目名称:spike.x,代码行数:21,代码来源:DefaultHttpConnectionHealthChecker.java

示例2: parseData

import org.vertx.java.core.http.HttpClientResponse; //导入方法依赖的package包/类
private void parseData(HttpClientResponse response, final Handler<JsonObject> handler) {
    if (response.statusCode() == 200) {
        final Buffer buff = new Buffer();
        response.dataHandler(new Handler<Buffer>() {
            @Override
            public void handle(Buffer event) {
                buff.appendBuffer(event);
            }
        });
        response.endHandler(new Handler<Void>() {
            @Override
            public void handle(Void end) {
                handleResponse(buff.toString(), handler);
            }
        });
    } else {
        handler.handle(new JsonObject().putString("status", "error").putString("message", response.statusMessage()));
    }
}
 
开发者ID:OPEN-ENT-NG,项目名称:collaborative-editor,代码行数:20,代码来源:EPLiteConnection.java

示例3: handle

import org.vertx.java.core.http.HttpClientResponse; //导入方法依赖的package包/类
@Override
public void handle(final HttpClientResponse response) {
    final int statusCode = response.statusCode();                    
    logger.trace("[RESPONSE-" + getId() + "] statuscode: " + statusCode + ", time: " + timeFormatter.format(new Date()));
    response.bodyHandler(new Handler<Buffer>() {
        @Override
        public void handle(Buffer body) {
            // The entire response body has been received
            JsonObject restResponse = new JsonObject();
            responseData.append(body);
            logger.trace("> response: (" + getId() + ")" + responseData);
            if (responseData != null && responseData.length() > 0) {
                if (responseData.toString().startsWith("[")) restResponse = new JsonArray(responseData.toString()).get(0);
                else restResponse = new JsonObject(responseData.toString());
            }
            
            // send response
            if (statusCode >= 200 && statusCode < 300) sendResponse(true, statusCode, restResponse);
            else sendResponse(false, statusCode, restResponse);
            
            logger.trace("[RESPONSE-" + getId() + "] body parsed" + ", time: " + timeFormatter.format(new Date()));
        }
    });
}
 
开发者ID:santo74,项目名称:vertx-arangodb,代码行数:25,代码来源:RestResponseHandler.java

示例4: handleFailure

import org.vertx.java.core.http.HttpClientResponse; //导入方法依赖的package包/类
@Override
protected void handleFailure(final HttpClientResponse response) {
    if (response.statusCode() != 200) {
        m_logger.error("Failed to execute query: {}",
                m_query,
                new IllegalStateException("HTTP get failure: "
                        + response.statusCode()
                        + "/"
                        + response.statusMessage()));
    }
}
 
开发者ID:clidev,项目名称:spike.x,代码行数:12,代码来源:Ubidots.java

示例5: handle

import org.vertx.java.core.http.HttpClientResponse; //导入方法依赖的package包/类
@Override
public void handle(final HttpClientResponse response) {
    if (response.statusCode() >= HTTP_ERR_CODE) {
        handleFailure(response);
    } else {
        handleSuccess(response);
    }
}
 
开发者ID:clidev,项目名称:spike.x,代码行数:9,代码来源:HttpClientResponseAdapter.java

示例6: handle

import org.vertx.java.core.http.HttpClientResponse; //导入方法依赖的package包/类
@Override
public void handle(final HttpClientResponse response) {
	if (response.statusCode() == Status.ACCEPTED.getStatusCode()) {
		logger.debug("Reply sent successfully");
	} else {
		logger.warn("Error sending the reply to client. status code:" + response.statusCode()
				    + "  message: " + response.statusMessage());
	}
}
 
开发者ID:j2ro,项目名称:mod-http-event-bus-bridge,代码行数:10,代码来源:HttpResponseHandler.java

示例7: httpHealthCheck

import org.vertx.java.core.http.HttpClientResponse; //导入方法依赖的package包/类
private void httpHealthCheck(
        final HttpConnection connection,
        final HttpClientResponse response,
        final Handler<Boolean> handler) {

    m_logger.trace("Got response: {}/{}",
            response.statusCode(),
            response.statusMessage());

    if (response.statusCode() < HTTP_ERR_CODE) {

        final Buffer body = new Buffer(0);
        response.dataHandler(new Handler<Buffer>() {
            @Override
            public void handle(final Buffer data) {
                if (response.statusCode() >= HTTP_SUCCESS_CODE
                        && response.statusCode() < HTTP_REDIRECTION_CODE) {

                    body.appendBuffer(data);
                }
            }
        });
        response.endHandler(new VoidHandler() {
            @Override
            public void handle() {
                if (response.statusCode() >= HTTP_SUCCESS_CODE
                        && response.statusCode() < HTTP_REDIRECTION_CODE) {

                    String status = new String(body.getBytes(), StandardCharsets.UTF_8);
                    connection.setConnected(true);
                    if (handler != null) {
                        handler.handle(TRUE);
                    }
                    m_logger.trace("Connected to healthy host: {} ({})",
                            connection.getAddress(), status);
                } else {
                    handleFailure(connection, response, handler);
                }
            }
        });
    } else {
        handleFailure(connection, response, handler);
    }
}
 
开发者ID:clidev,项目名称:spike.x,代码行数:45,代码来源:DefaultHttpConnectionHealthChecker.java


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