• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java EnglishReasonPhraseCatalog类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getHttpStatusCodes

import org.apache.http.impl.EnglishReasonPhraseCatalog; //导入依赖的package包/类
/**
 * Method returns list of http status codes.
 *
 * @param binaryAnnotations zipkin binary annotations
 * @return http status codes
 */
public static List<HttpCode> getHttpStatusCodes(List<BinaryAnnotation> binaryAnnotations) {
    if (binaryAnnotations == null) {
        return Collections.emptyList();
    }

    List<HttpCode> httpCodes = new ArrayList<>();

    for (BinaryAnnotation binaryAnnotation: binaryAnnotations) {
        if (Constants.ZIPKIN_BIN_ANNOTATION_HTTP_STATUS_CODE.equals(binaryAnnotation.getKey()) &&
                binaryAnnotation.getValue() != null) {

            String strHttpCode = binaryAnnotation.getValue();
            Integer httpCode = toInt(strHttpCode.trim());

            if (httpCode != null) {
                String description = EnglishReasonPhraseCatalog.INSTANCE.getReason(httpCode, Locale.ENGLISH);
                httpCodes.add(new HttpCode(httpCode, description));
            }
        }

    }
    return httpCodes;
}
 
开发者ID:hawkular,项目名称:hawkular-apm,代码行数:30,代码来源:SpanHttpDeriverUtil.java


示例2: generateResponse

import org.apache.http.impl.EnglishReasonPhraseCatalog; //导入依赖的package包/类
private Response generateResponse(String contentType, int status, byte[] content) {
    final BasicStatusLine statusLine = new BasicStatusLine(
        new ProtocolVersion("HTTP", 1, 1),
        status,
        EnglishReasonPhraseCatalog.INSTANCE.getReason(status, Locale.ENGLISH));

    final BasicHttpResponse httpResponse = new BasicHttpResponse(statusLine);
    httpResponse.addHeader("Content-Type", contentType);

    final HttpResponseDecorator httpResponseDecorator = new HttpResponseDecorator(httpResponse, content);
    final RestAssuredResponseImpl restResponse = new RestAssuredResponseImpl();
    restResponse.setStatusCode(status);
    restResponse.parseResponse(
        httpResponseDecorator,
        content,
        false,
        new ResponseParserRegistrar()
    );

    return restResponse;
}
 
开发者ID:ctco,项目名称:cukes,代码行数:22,代码来源:HttpAssertionFacadeImplTest.java


示例3: failed

import org.apache.http.impl.EnglishReasonPhraseCatalog; //导入依赖的package包/类
public void failed(final Exception ex) {
    synchronized (this.httpExchange) {
        if (this.completed) {
            return;
        }
        this.completed = true;
        this.httpExchange.setException(ex);
        HttpAsyncExchange responseTrigger = this.httpExchange.getResponseTrigger();
        if (responseTrigger != null && !responseTrigger.isCompleted()) {
            System.out.println("[client<-proxy] " + this.httpExchange.getId() + " " + ex);
            ConsoleFactory.printToConsole("[client<-proxy] " + this.httpExchange.getId() + " " + ex,true);
            int status = HttpStatus.SC_INTERNAL_SERVER_ERROR;
            HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_0, status,
                    EnglishReasonPhraseCatalog.INSTANCE.getReason(status, Locale.US));
            String message = ex.getMessage();
            if (message == null) {
                message = "Unexpected error";
            }
            response.setEntity(new NStringEntity(message, ContentType.DEFAULT_TEXT));
            responseTrigger.submitResponse(new BasicAsyncResponseProducer(response));
        }
    }
}
 
开发者ID:HuaweiSNC,项目名称:OpsDev,代码行数:24,代码来源:NHttpReverseProxy.java


示例4: getHttpResponseHeadMethodTest

import org.apache.http.impl.EnglishReasonPhraseCatalog; //导入依赖的package包/类
@Test
public final void getHttpResponseHeadMethodTest() throws TranslationException, UnsupportedEncodingException {
	// create the coap response
	Response coapResponse = new Response(CodeRegistry.RESP_CREATED);
	String payload = "aaa";
	coapResponse.setPayload(payload.getBytes("UTF-8"));

	// create the http response
	HttpRequest httpRequest = new BasicHttpRequest("HEAD", "coap://localhost");

	// translate the http response
	HttpResponse httpResponse = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, EnglishReasonPhraseCatalog.INSTANCE.getReason(200, Locale.ENGLISH));
	HttpTranslator.getHttpResponse(httpRequest, coapResponse, httpResponse);

	// check
	assertNotNull(httpResponse);
	assertTrue(httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_CREATED);

	// check the payload
	assertFalse(httpResponse.containsHeader("content-type"));
	assertNull(httpResponse.getEntity());

	// check the headers
	assertNotNull(httpResponse.getAllHeaders());
	assertEquals(1, httpResponse.getAllHeaders().length);
}
 
开发者ID:Orange-OpenSource,项目名称:holico,代码行数:27,代码来源:HttpTranslatorTest.java


示例5: buildResponseMethodName

import org.apache.http.impl.EnglishReasonPhraseCatalog; //导入依赖的package包/类
/**
 * <p>buildResponseMethodName.</p>
 *
 * @param statusCode a int.
 * @param mimeType a {@link org.aml.apimodel.MimeType} object.
 * @return a {@link java.lang.String} object.
 */
public static String buildResponseMethodName(final int statusCode, final MimeType mimeType)
{
    final String status = EnglishReasonPhraseCatalog.INSTANCE.getReason(statusCode, DEFAULT_LOCALE);
    
   String string = getShortMimeType(mimeType)
                          + buildJavaFriendlyName(defaultIfBlank(status, "_" + statusCode));
   return "with" + Character.toUpperCase(string.charAt(0))+string.substring(1);
}
 
开发者ID:OnPositive,项目名称:aml,代码行数:16,代码来源:Names.java


示例6: getResponse

import org.apache.http.impl.EnglishReasonPhraseCatalog; //导入依赖的package包/类
public static HttpResponse getResponse(int expectedStatus, String expectedBody) {
  ProtocolVersion version = new ProtocolVersion("HTTP", 1, 1);
  StatusLine statusLine = new BasicStatusLine(version, expectedStatus, EnglishReasonPhraseCatalog.INSTANCE.getReason(expectedStatus, Locale.US));
  HttpResponse response = new BasicHttpResponse(statusLine);
  response.setEntity(new StringEntity(expectedBody, Charset.forName("UTF-8")));
  return response;
}
 
开发者ID:TempoIQ,项目名称:tempoiq-java,代码行数:8,代码来源:Util.java


示例7: sendSimpleHttpResponse

import org.apache.http.impl.EnglishReasonPhraseCatalog; //导入依赖的package包/类
/**
 * Send simple http response.
 * 
 * @param httpExchange
 *            the http exchange
 * @param httpCode
 *            the http code
 */
private void sendSimpleHttpResponse(HttpAsyncExchange httpExchange, int httpCode) {
	// get the empty response from the exchange
	HttpResponse httpResponse = httpExchange.getResponse();

	// create and set the status line
	StatusLine statusLine = new BasicStatusLine(HttpVersion.HTTP_1_1, httpCode, EnglishReasonPhraseCatalog.INSTANCE.getReason(httpCode, Locale.ENGLISH));
	httpResponse.setStatusLine(statusLine);

	// send the error response
	httpExchange.submitResponse();
}
 
开发者ID:Orange-OpenSource,项目名称:holico,代码行数:20,代码来源:HttpStack.java


示例8: getCoapResponseNoContentTest

import org.apache.http.impl.EnglishReasonPhraseCatalog; //导入依赖的package包/类
@Test
public final void getCoapResponseNoContentTest() throws TranslationException {
	// create the response
	StatusLine statusLine = new BasicStatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_NO_CONTENT, EnglishReasonPhraseCatalog.INSTANCE.getReason(HttpStatus.SC_NO_CONTENT, Locale.ENGLISH));
	HttpResponse httpResponse = new BasicHttpResponse(statusLine);

	// translate the http response
	Response coapResponse = HttpTranslator.getCoapResponse(httpResponse, new GETRequest());

	assertNotNull(coapResponse);
	assertTrue(coapResponse.getCode() == CodeRegistry.RESP_CHANGED);

	coapResponse = HttpTranslator.getCoapResponse(httpResponse, new POSTRequest());

	assertNotNull(coapResponse);
	assertTrue(coapResponse.getCode() == CodeRegistry.RESP_CHANGED);

	coapResponse = HttpTranslator.getCoapResponse(httpResponse, new PUTRequest());

	assertNotNull(coapResponse);
	assertTrue(coapResponse.getCode() == CodeRegistry.RESP_CHANGED);

	coapResponse = HttpTranslator.getCoapResponse(httpResponse, new DELETERequest());

	assertNotNull(coapResponse);
	assertTrue(coapResponse.getCode() == CodeRegistry.RESP_DELETED);
}
 
开发者ID:Orange-OpenSource,项目名称:holico,代码行数:28,代码来源:HttpTranslatorTest.java


示例9: getHttpResponseErrorCodeTest

import org.apache.http.impl.EnglishReasonPhraseCatalog; //导入依赖的package包/类
@Test
public final void getHttpResponseErrorCodeTest() throws TranslationException, IOException {
	// create the coap response
	Response coapResponse = new Response(CodeRegistry.RESP_NOT_FOUND);
	String reason = "custom reason";
	coapResponse.setPayload(reason.getBytes("UTF-8"));

	// create the http response
	HttpRequest httpRequest = new BasicHttpRequest("GET", "coap://localhost");

	// translate the http response
	HttpResponse httpResponse = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, EnglishReasonPhraseCatalog.INSTANCE.getReason(200, Locale.ENGLISH));
	HttpTranslator.getHttpResponse(httpRequest, coapResponse, httpResponse);

	// check
	assertNotNull(httpResponse);
	assertTrue(httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_NOT_FOUND);

	// check the payload
	assertEquals(ContentType.TEXT_PLAIN.toString().toLowerCase(), httpResponse.getFirstHeader("content-type").getValue().toLowerCase());
	byte[] byteArrayActual = getByteArray(httpResponse.getEntity().getContent());
	byte[] bytesExpected = reason.getBytes("ISO-8859-1");
	assertArrayEquals(bytesExpected, byteArrayActual);

	// check the headers
	assertNotNull(httpResponse.getAllHeaders());
	assertEquals(2, httpResponse.getAllHeaders().length);
}
 
开发者ID:Orange-OpenSource,项目名称:holico,代码行数:29,代码来源:HttpTranslatorTest.java


示例10: getHttpResponseTest

import org.apache.http.impl.EnglishReasonPhraseCatalog; //导入依赖的package包/类
/**
 * Test method for
 * {@link ch.ethz.inf.vs.californium.util.HttpTranslator#getHttpResponse(ch.ethz.inf.vs.californium.coap.Response, org.apache.http.HttpResponse)}
 * .
 * 
 * @throws IOException
 */
@Test
public final void getHttpResponseTest() throws TranslationException, IOException {
	// create the coap response
	Response coapResponse = new Response(CodeRegistry.RESP_CREATED);
	String payload = "aaa";
	coapResponse.setPayload(payload.getBytes("UTF-8"));
	coapResponse.setContentType(MediaTypeRegistry.TEXT_PLAIN);
	String etag = "254636899";
	coapResponse.setOption(new Option(etag, OptionNumberRegistry.ETAG));

	// create the http response
	HttpRequest httpRequest = new BasicHttpRequest("POST", "coap://localhost");

	// translate the http response
	HttpResponse httpResponse = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, EnglishReasonPhraseCatalog.INSTANCE.getReason(200, Locale.ENGLISH));
	HttpTranslator.getHttpResponse(httpRequest, coapResponse, httpResponse);

	// check
	assertNotNull(httpResponse);
	assertTrue(httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_CREATED);

	// check the payload
	assertEquals(ContentType.TEXT_PLAIN.toString().toLowerCase(), httpResponse.getFirstHeader("content-type").getValue().toLowerCase());
	byte[] byteArrayActual = getByteArray(httpResponse.getEntity().getContent());
	byte[] bytesExpected = payload.getBytes("ISO-8859-1");
	assertArrayEquals(bytesExpected, byteArrayActual);

	// check the headers
	assertNotNull(httpResponse.getAllHeaders());
	assertEquals(3, httpResponse.getAllHeaders().length);
	assertEquals(etag, httpResponse.getFirstHeader("etag").getValue().toLowerCase());
}
 
开发者ID:Orange-OpenSource,项目名称:holico,代码行数:40,代码来源:HttpTranslatorTest.java


示例11: getHttpResponseWrongCodeTest

import org.apache.http.impl.EnglishReasonPhraseCatalog; //导入依赖的package包/类
@Test(expected = TranslationException.class)
public final void getHttpResponseWrongCodeTest() throws TranslationException {
	// create the coap response
	Response coapResponse = new Response(CodeRegistry.EMPTY_MESSAGE);

	// create the http response
	HttpRequest httpRequest = new BasicHttpRequest("POST", "coap://localhost");

	// translate the http response
	HttpResponse httpResponse = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, EnglishReasonPhraseCatalog.INSTANCE.getReason(200, Locale.ENGLISH));
	HttpTranslator.getHttpResponse(httpRequest, coapResponse, httpResponse);
}
 
开发者ID:Orange-OpenSource,项目名称:holico,代码行数:13,代码来源:HttpTranslatorTest.java


示例12: getCoapResponseTest

import org.apache.http.impl.EnglishReasonPhraseCatalog; //导入依赖的package包/类
/**
 * Test method for
 * {@link ch.ethz.inf.vs.californium.util.HttpTranslator#getCoapResponse(org.apache.http.HttpResponse)}
 * .
 * 
 * @throws IllegalAccessException
 * @throws TranslationException
 */
@Test
public final void getCoapResponseTest() throws IllegalAccessException, TranslationException {
	for (Field field : HttpStatus.class.getDeclaredFields()) {
		// get the code
		int httpCode = field.getInt(null);
		// if(http)

		// create the response
		StatusLine statusLine = new BasicStatusLine(HttpVersion.HTTP_1_1, httpCode, EnglishReasonPhraseCatalog.INSTANCE.getReason(httpCode, Locale.ENGLISH));
		HttpResponse httpResponse = new BasicHttpResponse(statusLine);

		// create the entity
		String contentString = "aaa";
		HttpEntity httpEntity = new ByteArrayEntity(contentString.getBytes(Charset.forName("ISO_8859_1")), ContentType.TEXT_PLAIN);
		httpResponse.setEntity(httpEntity);

		// set the content-type
		httpResponse.setHeader("content-type", "text/plain;  charset=iso-8859-1");

		// create the header
		String headerName = "if-match";
		String headerValue = "\"737060cd8c284d8af7ad3082f209582d\"";
		Header header = new BasicHeader(headerName, headerValue);
		httpResponse.addHeader(header);

		// translate the http response
		Response coapResponse = HttpTranslator.getCoapResponse(httpResponse, new GETRequest());
		assertNotNull(coapResponse);

		// check the payload
		assertNotNull(coapResponse.getPayload());
		assertArrayEquals(contentString.getBytes(Charset.forName("UTF-8")), coapResponse.getPayload());

		// check the option
		assertFalse(coapResponse.getOptions().isEmpty());
		int optionNumber = Integer.parseInt(HttpTranslator.HTTP_TRANSLATION_PROPERTIES.getProperty("http.message.header." + headerName));
		assertEquals(coapResponse.getFirstOption(optionNumber).getStringValue(), headerValue);

		// check the content-type
		assertEquals(coapResponse.getContentType(), MediaTypeRegistry.TEXT_PLAIN);
	}
}
 
开发者ID:Orange-OpenSource,项目名称:holico,代码行数:51,代码来源:HttpTranslatorTest.java


示例13: getHttpResponseNullTest

import org.apache.http.impl.EnglishReasonPhraseCatalog; //导入依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public final void getHttpResponseNullTest() throws TranslationException {
	HttpResponse httpResponse = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, EnglishReasonPhraseCatalog.INSTANCE.getReason(200, Locale.ENGLISH));
	HttpTranslator.getHttpResponse(null, new Response(0), httpResponse);
}
 
开发者ID:Orange-OpenSource,项目名称:holico,代码行数:6,代码来源:HttpTranslatorTest.java


示例14: getHttpResponseNullTest2

import org.apache.http.impl.EnglishReasonPhraseCatalog; //导入依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public final void getHttpResponseNullTest2() throws TranslationException {
	HttpResponse httpResponse = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, EnglishReasonPhraseCatalog.INSTANCE.getReason(200, Locale.ENGLISH));
	HttpTranslator.getHttpResponse(new BasicHttpRequest("get", "http://localhost"), null, httpResponse);
}
 
开发者ID:Orange-OpenSource,项目名称:holico,代码行数:6,代码来源:HttpTranslatorTest.java


示例15: DefaultHttpResponseFactory

import org.apache.http.impl.EnglishReasonPhraseCatalog; //导入依赖的package包/类
/**
 * Creates a new response factory with the default catalog.
 * The default catalog is {@link EnglishReasonPhraseCatalog}.
 */
public DefaultHttpResponseFactory() {
    this(EnglishReasonPhraseCatalog.INSTANCE);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:DefaultHttpResponseFactory.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java NgWebDriver类代码示例发布时间:2022-05-22
下一篇:
Java FragmentEvent类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap