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


Java HeaderUtils类代码示例

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


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

示例1: aroundWriteTo

import org.glassfish.jersey.message.internal.HeaderUtils; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void aroundWriteTo(final WriterInterceptorContext writerInterceptorContext)
        throws IOException, WebApplicationException {
    final LoggingStream stream = (LoggingStream) writerInterceptorContext.getProperty(ENTITY_LOGGER_PROPERTY);
    writerInterceptorContext.proceed();

    final Object requestId = Requests.getProperty(LOGGING_ID_PROPERTY);
    final long id = requestId != null ? (Long) requestId : _id.incrementAndGet();
    StringBuilder b = (StringBuilder) writerInterceptorContext.getProperty(LOGGER_BUFFER_PROPERTY);
    if (b == null) {
        b = new StringBuilder();
        writerInterceptorContext.setProperty(LOGGER_BUFFER_PROPERTY, b);
    }
    printPrefixedHeaders(b, id, RESPONSE_PREFIX, HeaderUtils.asStringHeaders(writerInterceptorContext.getHeaders()));

    if (stream != null) {
        log(stream.getStringBuilder(MessageUtils.getCharset(writerInterceptorContext.getMediaType())));
    } else {
        log(b);
    }
}
 
开发者ID:icode,项目名称:ameba,代码行数:25,代码来源:LoggingFilter.java

示例2: writeOutBoundHeaders

import org.glassfish.jersey.message.internal.HeaderUtils; //导入依赖的package包/类
private static Map<String, String> writeOutBoundHeaders(final MultivaluedMap<String, Object> headers,
                                                        final HttpUriRequest request) {
    final Map<String, String> stringHeaders = HeaderUtils.asStringHeadersSingleValue(headers);
    for(final Map.Entry<String, String> e : stringHeaders.entrySet()) {
        request.addHeader(e.getKey(), e.getValue());
    }
    return stringHeaders;
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:9,代码来源:HttpComponentsConnector.java

示例3: writeOutBoundHeaders

import org.glassfish.jersey.message.internal.HeaderUtils; //导入依赖的package包/类
private static Map<String, String> writeOutBoundHeaders(final MultivaluedMap<String, Object> headers,
                                                        final HttpUriRequest request) {
    final Map<String, String> stringHeaders = HeaderUtils.asStringHeadersSingleValue(headers);

    for (final Map.Entry<String, String> e : stringHeaders.entrySet()) {
        request.addHeader(e.getKey(), e.getValue());
    }
    return stringHeaders;
}
 
开发者ID:fod-dev,项目名称:FoDBugTrackerUtility,代码行数:10,代码来源:ApacheConnector.java

示例4: apply

import org.glassfish.jersey.message.internal.HeaderUtils; //导入依赖的package包/类
@Override
public ClientResponse apply(final ClientRequest clientRequest) throws ProcessingException {
    final HttpUriRequest request = this.toUriHttpRequest(clientRequest);
    final Map<String, String> clientHeadersSnapshot = writeOutBoundHeaders(clientRequest.getHeaders(), request);

    try {
        final CloseableHttpResponse response;
        response = client.execute(new HttpHost(request.getURI().getHost(), request.getURI().getPort(), request.getURI().getScheme()), request, new BasicHttpContext(context));
        HeaderUtils.checkHeaderChanges(clientHeadersSnapshot, clientRequest.getHeaders(), this.getClass().getName());

        final Response.StatusType status = response.getStatusLine().getReasonPhrase() == null
                ? Statuses.from(response.getStatusLine().getStatusCode())
                : Statuses.from(response.getStatusLine().getStatusCode(), response.getStatusLine().getReasonPhrase());

        final ClientResponse responseContext = new ClientResponse(status, clientRequest);
        final List<URI> redirectLocations = context.getRedirectLocations();
        if(redirectLocations != null && !redirectLocations.isEmpty()) {
            responseContext.setResolvedRequestUri(redirectLocations.get(redirectLocations.size() - 1));
        }

        final Header[] respHeaders = response.getAllHeaders();
        final MultivaluedMap<String, String> headers = responseContext.getHeaders();
        for(final Header header : respHeaders) {
            final String headerName = header.getName();
            List<String> list = headers.get(headerName);
            if(list == null) {
                list = new ArrayList<>();
            }
            list.add(header.getValue());
            headers.put(headerName, list);
        }

        final HttpEntity entity = response.getEntity();

        if(entity != null) {
            if(headers.get(HttpHeaders.CONTENT_LENGTH) == null) {
                headers.add(HttpHeaders.CONTENT_LENGTH, String.valueOf(entity.getContentLength()));
            }

            final Header contentEncoding = entity.getContentEncoding();
            if(headers.get(HttpHeaders.CONTENT_ENCODING) == null && contentEncoding != null) {
                headers.add(HttpHeaders.CONTENT_ENCODING, contentEncoding.getValue());
            }
        }
        responseContext.setEntityStream(this.toInputStream(response));
        return responseContext;
    }
    catch(final Exception e) {
        throw new ProcessingException(e);
    }
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:52,代码来源:HttpComponentsConnector.java

示例5: getHeaderString

import org.glassfish.jersey.message.internal.HeaderUtils; //导入依赖的package包/类
/**
 * <p>getHeaderString.</p>
 *
 * @param headers a {@link javax.ws.rs.core.MultivaluedMap} object.
 * @param name a {@link java.lang.String} object.
 * @return a {@link java.lang.String} object.
 */
public static String getHeaderString(MultivaluedMap<String, Object> headers, String name) {
    return HeaderUtils.asHeaderString(headers.get(name), RuntimeDelegate.getInstance());
}
 
开发者ID:icode,项目名称:ameba,代码行数:11,代码来源:MessageHelper.java


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