本文整理汇总了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()));
}
}
示例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()));
}
}
示例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()));
}
});
}
示例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()));
}
}
示例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);
}
}
示例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());
}
}
示例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);
}
}