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


Java HeaderConstants类代码示例

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


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

示例1: noCache

import org.restlet.engine.header.HeaderConstants; //导入依赖的package包/类
/**
 * Creates a "no-cache" directive. Indicates that a cache must not use the
 * response to satisfy subsequent requests without successful revalidation
 * with the origin server.<br>
 * <br>
 * Note that this directive can be used on requests or responses.
 * 
 * @param fieldNames
 *            Field names, typically a HTTP header name, that must not be
 *            sent by caches.
 * @return A new "no-cache" directive.
 * @see <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9.1">HTTP 1.1 - What is Cacheable</a>
 */
public static CacheDirective noCache(List<String> fieldNames) {
    StringBuilder sb = new StringBuilder();

    if (fieldNames != null) {
        for (int i = 0; i < fieldNames.size(); i++) {
            sb.append("\"" + fieldNames.get(i) + "\"");

            if (i < fieldNames.size() - 1) {
                sb.append(',');
            }
        }
    }

    return new CacheDirective(HeaderConstants.CACHE_NO_CACHE, sb.toString());
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:29,代码来源:CacheDirective.java

示例2: privateInfo

import org.restlet.engine.header.HeaderConstants; //导入依赖的package包/类
/**
 * Creates a "private" directive. Indicates that all or part of the response
 * message is intended for a single user and must not be cached by a shared
 * cache.<br>
 * <br>
 * Note that this directive can be used on responses only.
 * 
 * @param fieldNames
 *            Field names, typically a HTTP header name, that must be
 *            private.
 * @return A new "private" directive.
 * @see <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9.1">HTTP 1.1 - What is Cacheable</a>
 */
public static CacheDirective privateInfo(List<String> fieldNames) {
    StringBuilder sb = new StringBuilder();

    if (fieldNames != null) {
        for (int i = 0; i < fieldNames.size(); i++) {
            sb.append("\"" + fieldNames.get(i) + "\"");

            if (i < fieldNames.size() - 1) {
                sb.append(',');
            }
        }
    }

    return new CacheDirective(HeaderConstants.CACHE_PRIVATE, sb.toString());
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:29,代码来源:CacheDirective.java

示例3: processHeaders

import org.restlet.engine.header.HeaderConstants; //导入依赖的package包/类
/**
 * Updates the request method based on specific header.
 * 
 * @param request
 *            The request to update.
 */
@SuppressWarnings("unchecked")
private void processHeaders(Request request) {
    final TunnelService tunnelService = getTunnelService();

    if (tunnelService.isMethodTunnel()) {
        // get the headers
        Series<Header> extraHeaders = (Series<Header>) request
                .getAttributes().get(HeaderConstants.ATTRIBUTE_HEADERS);

        if (extraHeaders != null) {
            // look for the new value of the method
            final String newMethodValue = extraHeaders.getFirstValue(
                    getTunnelService().getMethodHeader(), true);

            if (newMethodValue != null
                    && newMethodValue.trim().length() > 0) {
                // set the current method to the new method
                request.setMethod(Method.valueOf(newMethodValue));
            }
        }
    }
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:29,代码来源:TunnelFilter.java

示例4: getChallengeResponse

import org.restlet.engine.header.HeaderConstants; //导入依赖的package包/类
@Override
public ChallengeResponse getChallengeResponse() {
    ChallengeResponse result = super.getChallengeResponse();

    if (!this.securityAdded) {
        // Extract the header value
        String authorization = getHeaders().getValues(HeaderConstants.HEADER_AUTHORIZATION);

        // Set the challenge response
        result = AuthenticatorUtils.parseResponse(this, authorization, getHeaders());
        setChallengeResponse(result);
        this.securityAdded = true;
    }

    return result;
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:17,代码来源:HttpServerRequest.java

示例5: getCookies

import org.restlet.engine.header.HeaderConstants; //导入依赖的package包/类
/**
 * Returns the cookies provided by the client.
 * 
 * @return The cookies provided by the client.
 */
@Override
public Series<Cookie> getCookies() {
    Series<Cookie> result = super.getCookies();

    if (!this.cookiesAdded) {
        String cookieValues = getHeaders().getValues(HeaderConstants.HEADER_COOKIE);

        if (cookieValues != null) {
            new CookieReader(cookieValues).addValues(result);
        }

        this.cookiesAdded = true;
    }

    return result;
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:22,代码来源:HttpServerRequest.java

示例6: getHeaders

import org.restlet.engine.header.HeaderConstants; //导入依赖的package包/类
@Override
public Series<Header> getHeaders() {
    final Series<Header> result = super.getHeaders();

    if (!this.headersAdded) {
        Entry<CharSequence, CharSequence> header = null;

        for (Iterator<Entry<CharSequence, CharSequence>> headers = getNettyRequest().headers()
                .iteratorCharSequence(); headers.hasNext();) {
            header = headers.next();
            result.add(header.getKey().toString(), header.getValue().toString());
        }

        getAttributes().put(HeaderConstants.ATTRIBUTE_HEADERS,
                result);
        this.headersAdded = true;
    }

    return result;
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:21,代码来源:HttpServerRequest.java

示例7: getProxyChallengeResponse

import org.restlet.engine.header.HeaderConstants; //导入依赖的package包/类
@Override
public ChallengeResponse getProxyChallengeResponse() {
    ChallengeResponse result = super.getProxyChallengeResponse();

    if (!this.proxySecurityAdded) {
        // Extract the header value
        final String authorization = getHeaders().getValues(HeaderConstants.HEADER_PROXY_AUTHORIZATION);

        // Set the challenge response
        result = AuthenticatorUtils.parseResponse(this, authorization, getHeaders());
        setProxyChallengeResponse(result);
        this.proxySecurityAdded = true;
    }

    return result;
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:17,代码来源:HttpServerRequest.java

示例8: parseHost

import org.restlet.engine.header.HeaderConstants; //导入依赖的package包/类
/**
 * Parses the "host" header to set the server host and port properties.
 */
private void parseHost() {
    String host = getHeaders().getFirstValue(HeaderConstants.HEADER_HOST, true);

    if (host != null) {
        // Take care of IPV6 addresses
        int colonIndex = host.indexOf(':', host.indexOf(']'));

        if (colonIndex != -1) {
            setHostDomain(host.substring(0, colonIndex));
            setHostPort(Integer.valueOf(host.substring(colonIndex + 1)));
        } else {
            setHostDomain(host);
            setHostPort(getProtocol().getDefaultPort());
        }
    } else {
        this.context.getLogger().info("Couldn't find the mandatory \"Host\" HTTP header.");
    }

    this.hostParsed = true;
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:24,代码来源:HttpServerRequest.java

示例9: getChallengeResponse

import org.restlet.engine.header.HeaderConstants; //导入依赖的package包/类
@Override
public ChallengeResponse getChallengeResponse() {
    ChallengeResponse result = super.getChallengeResponse();

    if (!this.securityAdded) {
        // Extract the header value
        String authorization = getHttpCall().getRequestHeaders().getValues(HeaderConstants.HEADER_AUTHORIZATION);

        // Set the challenge response
        result = AuthenticatorUtils.parseResponse(this, authorization, getHttpCall().getRequestHeaders());
        setChallengeResponse(result);
        this.securityAdded = true;
    }

    return result;
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:17,代码来源:HttpRequest.java

示例10: getCookies

import org.restlet.engine.header.HeaderConstants; //导入依赖的package包/类
/**
 * Returns the cookies provided by the client.
 * 
 * @return The cookies provided by the client.
 */
@Override
public Series<Cookie> getCookies() {
    Series<Cookie> result = super.getCookies();

    if (!this.cookiesAdded) {
        String cookieValues = getHttpCall().getRequestHeaders().getValues(HeaderConstants.HEADER_COOKIE);

        if (cookieValues != null) {
            new CookieReader(cookieValues).addValues(result);
        }

        this.cookiesAdded = true;
    }

    return result;
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:22,代码来源:HttpRequest.java

示例11: getProxyChallengeResponse

import org.restlet.engine.header.HeaderConstants; //导入依赖的package包/类
@Override
public ChallengeResponse getProxyChallengeResponse() {
    ChallengeResponse result = super.getProxyChallengeResponse();

    if (!this.proxySecurityAdded) {
        // Extract the header value
        final String authorization = getHttpCall().getRequestHeaders()
                .getValues(HeaderConstants.HEADER_PROXY_AUTHORIZATION);

        // Set the challenge response
        result = AuthenticatorUtils.parseResponse(this, authorization, getHttpCall().getRequestHeaders());
        setProxyChallengeResponse(result);
        this.proxySecurityAdded = true;
    }

    return result;
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:18,代码来源:HttpRequest.java

示例12: parseHost

import org.restlet.engine.header.HeaderConstants; //导入依赖的package包/类
/**
 * Parses the "host" header to set the server host and port properties.
 */
private void parseHost() {
    String host = getRequestHeaders().getFirstValue(
            HeaderConstants.HEADER_HOST, true);

    if (host != null) {
        // Take care of IPV6 addresses
        int colonIndex = host.indexOf(':', host.indexOf(']'));

        if (colonIndex != -1) {
            super.setHostDomain(host.substring(0, colonIndex));
            super.setHostPort(Integer.valueOf(host
                    .substring(colonIndex + 1)));
        } else {
            super.setHostDomain(host);
            super.setHostPort(getProtocol().getDefaultPort());
        }
    } else {
        getLogger().info(
                "Couldn't find the mandatory \"Host\" HTTP header.");
    }

    this.hostParsed = true;
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:27,代码来源:ServerCall.java

示例13: getOriginalRef

import org.restlet.engine.header.HeaderConstants; //导入依赖的package包/类
/**
 * Returns the original reference especially by detecting potential proxy forwardings.
 * 
 * @param resourceRef
 *            The request's resource reference.
 * @param headers
 *            The set of request's headers.
 * @return The original reference.
 */
public static Reference getOriginalRef(Reference resourceRef, Series<Header> headers) {
    Reference originalRef = resourceRef.getTargetRef();

    if (headers == null) {
        return originalRef;
    }
    
    String value = headers.getFirstValue(HeaderConstants.HEADER_X_FORWARDED_PORT);
    if (value != null) {
        originalRef.setHostPort(Integer.parseInt(value));
    }

    value = headers.getFirstValue(HeaderConstants.HEADER_X_FORWARDED_PROTO);
    if (value != null) {
        originalRef.setScheme(value);
    }

    return originalRef;
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:29,代码来源:ReferenceUtils.java

示例14: TunnelService

import org.restlet.engine.header.HeaderConstants; //导入依赖的package包/类
/**
 * Constructor.
 * 
 * @param enabled
 *            True if the service has been enabled.
 * @param methodTunnel
 *            Indicates if the method can be tunneled using a query
 *            parameter.
 * @param preferencesTunnel
 *            Indicates if the client preferences can be tunneled using
 *            query parameters or file-like extensions or user agent string.
 * @param queryTunnel
 *            Indicates if tunneling can use query parameters.
 * @param extensionsTunnel
 *            Indicates if tunneling can use file-like extensions.
 * @param userAgentTunnel
 *            Indicates if tunneling can use user agent string.
 * @param headersTunnel
 *            Indicates if method can be tunneled via a specific header.
 */
public TunnelService(boolean enabled, boolean methodTunnel,
        boolean preferencesTunnel, boolean queryTunnel,
        boolean extensionsTunnel, boolean userAgentTunnel,
        boolean headersTunnel) {
    super(enabled);

    this.extensionsTunnel = extensionsTunnel;
    this.methodTunnel = methodTunnel;
    this.preferencesTunnel = preferencesTunnel;
    this.queryTunnel = queryTunnel;
    this.userAgentTunnel = userAgentTunnel;
    this.headersTunnel = headersTunnel;

    this.characterSetParameter = "charset";
    this.encodingParameter = "encoding";
    this.languageParameter = "language";
    this.mediaTypeParameter = "media";
    this.methodParameter = "method";
    this.methodHeader = HeaderConstants.HEADER_X_HTTP_METHOD_OVERRIDE;
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:41,代码来源:TunnelService.java

示例15: pullData

import org.restlet.engine.header.HeaderConstants; //导入依赖的package包/类
/**
 * Pulls data from CloudStack API
 *
 * @return JSON string
 * @throws IOException
 */
private String pullData() throws IOException {
    logger.trace("Starting to pull data from provided URL");

    // create connection
    Client client = new Client(Protocol.HTTP);
    ClientResource cr = new ClientResource(url);
    Request req = cr.getRequest();

    // now header
    Series<Header> headerValue = new Series<Header>(Header.class);
    req.getAttributes().put(HeaderConstants.ATTRIBUTE_HEADERS, headerValue);
    headerValue.add("Accept", "application/json");
    headerValue.add("Content-Type", "application/json");

    // fire it up
    cr.get(MediaType.APPLICATION_JSON);
    Representation output = cr.getResponseEntity();

    logger.trace("Successfully pulled data from provided URL");

    // and return response data
    return output.getText();
}
 
开发者ID:icclab,项目名称:cyclops-udr,代码行数:30,代码来源:CloudStackDownloader.java


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