org.apache.http.HttpResponse.setReasonPhrase()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(5.0k)|赞(0)|评价(0)|浏览(169)

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

HttpResponse.setReasonPhrase介绍

[英]Updates the status line of this response with a new reason phrase. The status line can only be updated if it is available. It must have been set either explicitly or in a constructor.
[中]使用新的原因短语更新此响应的状态行。状态行只有在可用时才能更新。它必须已显式或在构造函数中设置。

代码示例

代码示例来源:origin: rest-assured/rest-assured

public void setReasonPhrase( String arg0 ) throws IllegalStateException {
  responseBase.setReasonPhrase( arg0 );
}

代码示例来源:origin: com.jayway.restassured/rest-assured

public void setReasonPhrase( String arg0 ) throws IllegalStateException {
  responseBase.setReasonPhrase( arg0 );
}

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

private void writeResponse(final HttpResponse resp, final String responseText, final int statusCode, final String responseType, final String reasonPhrase) {
  try {
    resp.setStatusCode(statusCode);
    resp.setReasonPhrase(reasonPhrase);
    final BasicHttpEntity body = new BasicHttpEntity();
    if (HttpUtils.RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) {
      // JSON response
      body.setContentType(JSONcontentType.value());
      if (responseText == null) {
        body.setContent(new ByteArrayInputStream("{ \"error\" : { \"description\" : \"Internal Server Error\" } }".getBytes(HttpUtils.UTF_8)));
      }
    } else {
      body.setContentType("text/xml");
      if (responseText == null) {
        body.setContent(new ByteArrayInputStream("<error>Internal Server Error</error>".getBytes(HttpUtils.UTF_8)));
      }
    }
    if (responseText != null) {
      body.setContent(new ByteArrayInputStream(responseText.getBytes(HttpUtils.UTF_8)));
    }
    resp.setEntity(body);
  } catch (final Exception ex) {
    s_logger.error("error!", ex);
  }
}

代码示例来源:origin: ibinti/bugvm

@Override
public void setReasonPhrase(final String reason) throws IllegalStateException {
  original.setReasonPhrase(reason);
}

代码示例来源:origin: com.github.paweladamski/HttpClientMock

public void setReasonPhrase(String reason) throws IllegalStateException {
  this.original.setReasonPhrase(reason);
}

代码示例来源:origin: com.hynnet/httpclient

@Override
public void setReasonPhrase(final String reason) throws IllegalStateException {
  original.setReasonPhrase(reason);
}

代码示例来源:origin: Nextdoor/bender

@Override
public void setReasonPhrase(final String reason) throws IllegalStateException {
  original.setReasonPhrase(reason);
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

@Override
public void setReasonPhrase(final String reason) throws IllegalStateException {
  original.setReasonPhrase(reason);
}

代码示例来源:origin: org.codehaus.groovy.modules.http-builder/http-builder

public void setReasonPhrase( String arg0 ) throws IllegalStateException {
  responseBase.setReasonPhrase( arg0 );
}

代码示例来源:origin: opencast/opencast

@Override public void setReasonPhrase(String s) throws IllegalStateException {
 response.setReasonPhrase(s);
}

代码示例来源:origin: com.bugvm/bugvm-rt

@Override
public void setReasonPhrase(final String reason) throws IllegalStateException {
  original.setReasonPhrase(reason);
}

代码示例来源:origin: org.esigate/esigate-core

@Override
public void setReasonPhrase(String reason) {
  httpResponse.setReasonPhrase(reason);
}

代码示例来源:origin: jgritman/httpbuilder

public void setReasonPhrase( String arg0 ) throws IllegalStateException {
  responseBase.setReasonPhrase( arg0 );
}

代码示例来源:origin: org.apache.httpcomponents/httpclient-android

public void setReasonPhrase(final String reason) throws IllegalStateException {
  original.setReasonPhrase(reason);
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.apache.httpcomponents.httpclient

public void setReasonPhrase(final String reason) throws IllegalStateException {
  original.setReasonPhrase(reason);
}

代码示例来源:origin: baidubce/bce-sdk-java

public void setReasonPhrase(final String reason) throws IllegalStateException {
  original.setReasonPhrase(reason);
}

代码示例来源:origin: com.jkoolcloud/jesl

/**
 * {@inheritDoc}
 */
@Override
public void setReasonPhrase(String reason) {
  if (response != null) {
    response.setReasonPhrase(reason);
  } else {
    super.setReasonPhrase(reason);
  }
}

代码示例来源:origin: wso2/wso2-synapse

response.setReasonPhrase(msg);
response.addHeader(CONTENT_TYPE, TEXT_HTML);
serverHandler.commitResponseHideExceptions(conn, response);

代码示例来源:origin: usnistgov/iheos-toolkit2

private void returnInternalError(HttpResponse response, ProxyLogger clientLogger, Throwable e) {
  boolean isFhir = true;
  if (isFhir) {
    OperationOutcome outcome = FhirSupport.operationOutcomeFromThrowable(e);
    FhirContext ctx = FileSystemResourceCache.getCtx();
    String content = ctx.newJsonParser().encodeResourceToString(outcome);
    clientLogger.logResponseEntity(content.getBytes());
    WrapResourceInHttpResponse.inResponse(response, "application/fhir+json", content);
  } else {
    response.setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR);
    response.setReasonPhrase("SimProxy error - " + e.getMessage().replaceAll("\n", "|"));
  }
  logger.error(ExceptionUtil.exception_details(e));
  clientLogger.logResponse(response);  // just logs the header
}

代码示例来源:origin: wso2/wso2-synapse

response.setReasonPhrase(msg);
response.addHeader(CONTENT_TYPE, TEXT_HTML);
sourceHandler.commitResponseHideExceptions(conn, response);

相关文章