org.asynchttpclient.Response.getStatusText()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(7.1k)|赞(0)|评价(0)|浏览(100)

本文整理了Java中org.asynchttpclient.Response.getStatusText方法的一些代码示例,展示了Response.getStatusText的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Response.getStatusText方法的具体详情如下:
包路径:org.asynchttpclient.Response
类名称:Response
方法名:getStatusText

Response.getStatusText介绍

[英]Returns the status text for the request.
[中]返回请求的状态文本。

代码示例

代码示例来源:origin: AsyncHttpClient/async-http-client

public String getStatusText() {
 return response.getStatusText();
}

代码示例来源:origin: AsyncHttpClient/async-http-client

private void fireCompleted(Response response) {
  if (listener != null) {
   listener.onCompleted(uri, response.getStatusCode(), response.getStatusText());
  }
 }
}

代码示例来源:origin: apache/pulsar

Response response = responseFuture.get();
if (response.getStatusCode() != HttpURLConnection.HTTP_OK) {
  log.warn("[{}] HTTP get request failed: {}", requestUrl, response.getStatusText());
  Exception e;
  if (response.getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) {
    e = new NotFoundException("Not found: " + response.getStatusText());
  } else {
    e = new PulsarClientException("HTTP get request failed: " + response.getStatusText());

代码示例来源:origin: AsyncHttpClient/async-http-client

/**
 * Converts async-http-client response to okhttp response.
 *
 * @param asyncHttpClientResponse async-http-client response
 * @return okhttp response.
 * @throws NullPointerException in case of null arguments
 */
private Response toOkhttpResponse(org.asynchttpclient.Response asyncHttpClientResponse) {
 // status code
 val rspBuilder = new Response.Builder()
     .request(request())
     .protocol(Protocol.HTTP_1_1)
     .code(asyncHttpClientResponse.getStatusCode())
     .message(asyncHttpClientResponse.getStatusText());
 // headers
 if (asyncHttpClientResponse.hasResponseHeaders()) {
  asyncHttpClientResponse.getHeaders().forEach(e -> rspBuilder.header(e.getKey(), e.getValue()));
 }
 // body
 if (asyncHttpClientResponse.hasResponseBody()) {
  val contentType = asyncHttpClientResponse.getContentType() == null
      ? null : MediaType.parse(asyncHttpClientResponse.getContentType());
  val okHttpBody = ResponseBody.create(contentType, asyncHttpClientResponse.getResponseBodyAsBytes());
  rspBuilder.body(okHttpBody);
 } else {
  rspBuilder.body(EMPTY_BODY);
 }
 return rspBuilder.build();
}

代码示例来源:origin: apache/incubator-druid

"Emissions of events not successful[%d: %s], with message[%s].",
  response.getStatusCode(),
  response.getStatusText(),
  response.getResponseBody(StandardCharsets.UTF_8).trim()
);

代码示例来源:origin: com.typesafe.play/play-java-ws

/**
 * Get the HTTP status text of the response
 */
@Override
public String getStatusText() {
  return ahcResponse.getStatusText();
}

代码示例来源:origin: org.asynchttpclient/async-http-client-api

public String getStatusText() {
  return response.getStatusText();
}

代码示例来源:origin: cloudbees/zendesk-java-client

private void logResponse(Response response) throws IOException {
  if (logger.isDebugEnabled()) {
    logger.debug("Response HTTP/{} {}\n{}", response.getStatusCode(), response.getStatusText(),
        response.getResponseBody());
  }
  if (logger.isTraceEnabled()) {
    logger.trace("Response headers {}", response.getHeaders());
  }
}

代码示例来源:origin: org.asynchttpclient/async-http-client-api

private void fireCompleted(Response response) {
    if (listener != null) {
      listener.onCompleted(uri, response.getStatusCode(), response.getStatusText());
    }
  }
}

代码示例来源:origin: cloudbees/zendesk-java-client

public ZendeskResponseException(Response resp) throws IOException {
  this(resp.getStatusCode(), resp.getStatusText(), resp.getResponseBody());
}

代码示例来源:origin: com.yahoo.bullet/bullet-storm

private void handleResponse(String id, Response response) {
    if (response == null || response.getStatusCode() != OK_200) {
      log.error("Handling error for id {} with response {}", id, response);
      responses.offer(new PubSubMessage(id, DRPCError.CANNOT_REACH_DRPC.asJSONClip()));
      return;
    }
    log.info("Received for id {}: {} {}", response.getStatusCode(), id, response.getStatusText());
    String body = response.getResponseBody();
    PubSubMessage message = PubSubMessage.fromJSON(body);
    log.debug("Received for id {}:\n{}", message.getId(), message.getContent());
    responses.offer(message);
  }
}

代码示例来源:origin: bullet-db/bullet-storm

private void handleResponse(String id, Response response) {
    if (response == null || response.getStatusCode() != OK_200) {
      log.error("Handling error for id {} with response {}", id, response);
      responses.offer(new PubSubMessage(id, DRPCError.CANNOT_REACH_DRPC.asJSONClip()));
      return;
    }
    log.info("Received for id {}: {} {}", response.getStatusCode(), id, response.getStatusText());
    String body = response.getResponseBody();
    PubSubMessage message = PubSubMessage.fromJSON(body);
    log.debug("Received for id {}:\n{}", message.getId(), message.getContent());
    responses.offer(message);
  }
}

代码示例来源:origin: bullet-db/bullet-storm

private Response getResponse(int status, String statusText, String body) {
  Response mock = mock(Response.class);
  doReturn(status).when(mock).getStatusCode();
  doReturn(statusText).when(mock).getStatusText();
  doReturn(body).when(mock).getResponseBody();
  return mock;
}

代码示例来源:origin: com.github.scribejava/scribejava-httpclient-ahc

@Override
public T onCompleted(org.asynchttpclient.Response ahcResponse) {
  try {
    final Map<String, String> headersMap = new HashMap<>();
    for (Map.Entry<String, String> header : ahcResponse.getHeaders()) {
      headersMap.put(header.getKey(), header.getValue());
    }
    final Response response = new Response(ahcResponse.getStatusCode(), ahcResponse.getStatusText(), headersMap,
        ahcResponse.getResponseBodyAsStream());
    @SuppressWarnings("unchecked")
    final T t = converter == null ? (T) response : converter.convert(response);
    if (callback != null) {
      callback.onCompleted(t);
    }
    return t;
  } catch (IOException | RuntimeException e) {
    onThrowable(e);
    return null;
  }
}

代码示例来源:origin: org.apache.pulsar/pulsar-client-original

Response response = responseFuture.get();
if (response.getStatusCode() != HttpURLConnection.HTTP_OK) {
  log.warn("[{}] HTTP get request failed: {}", requestUrl, response.getStatusText());
  Exception e;
  if (response.getStatusCode() == HttpURLConnection.HTTP_NOT_FOUND) {
    e = new NotFoundException("Not found: " + response.getStatusText());
  } else {
    e = new PulsarClientException("HTTP get request failed: " + response.getStatusText());

代码示例来源:origin: com.yahoo.pulsar/pulsar-client

Response response = responseFuture.get();
if (response.getStatusCode() != HttpURLConnection.HTTP_OK) {
  log.warn("[{}] HTTP get request failed: {}", requestUrl, response.getStatusText());
  future.completeExceptionally(
      new PulsarClientException("HTTP get request failed: " + response.getStatusText()));
  return;

代码示例来源:origin: metamx/java-util

"Emissions of events not successful[%d: %s], with message[%s].",
  response.getStatusCode(),
  response.getStatusText(),
  response.getResponseBody(StandardCharsets.UTF_8).trim()
);

代码示例来源:origin: Azure/azure-service-bus-java

exceptionMessage = parseDetailIfAvailable(exceptionMessage);
if (exceptionMessage == null) {
  exceptionMessage = response.getStatusText();

代码示例来源:origin: com.metamx/java-util

"Emissions of events not successful[%d: %s], with message[%s].",
  response.getStatusCode(),
  response.getStatusText(),
  response.getResponseBody(StandardCharsets.UTF_8).trim()
);

代码示例来源:origin: io.druid/java-util

"Emissions of events not successful[%d: %s], with message[%s].",
  response.getStatusCode(),
  response.getStatusText(),
  response.getResponseBody(StandardCharsets.UTF_8).trim()
);

相关文章