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


Java Header类代码示例

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


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

示例1: afterHandle

import org.restlet.engine.header.Header; //导入依赖的package包/类
@Override
protected void afterHandle(Request request, Response response) {
    if (!Method.OPTIONS.equals(request.getMethod())) {
        final Map<String, Object> responseAttributes = response.getAttributes();
        @SuppressWarnings("unchecked")
        Series<Header> responseHeaders = (Series<Header>) responseAttributes.get("org.restlet.http.headers");
        if (responseHeaders == null) {
            responseHeaders = new Series<Header>(Header.class);
            responseAttributes.put("org.restlet.http.headers", responseHeaders);
        }
        responseHeaders.add("Access-Control-Allow-Origin", "*");
       // responseHeaders.add("Access-Control-Allow-Methods", "GET,POST,DELETE,OPTIONS");
        responseHeaders.add("Access-Control-Allow-Headers", "Accept,Accept-Version,Content-Type,Api-Version,Authorization");
        responseHeaders.add("Access-Control-Allow-Credentials", "true");
        // responseHeaders.add("Access-Control-Max-Age", "60");
    }
    // }
    super.afterHandle(request, response);
}
 
开发者ID:freedomotic,项目名称:freedomotic,代码行数:20,代码来源:OriginFilter.java

示例2: addAllowOrigin

import org.restlet.engine.header.Header; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected void addAllowOrigin()
{
    Series<Header> responseHeaders = (Series<Header>) getResponse().getAttributes().get("org.restlet.http.headers");
    if (responseHeaders == null)
    {
        responseHeaders = new Series<>(Header.class);
        getResponse().getAttributes().put("org.restlet.http.headers", responseHeaders);
    }
    responseHeaders.add("Access-Control-Allow-Origin", "*");
    responseHeaders.add("Access-Control-Allow-Methods", "GET,POST,OPTIONS");
    responseHeaders.add("Access-Control-Allow-Headers", "Content-Type");
    responseHeaders.add("Access-Control-Allow-Credentials", "false");
    responseHeaders.add("Access-Control-Max-Age", "60");
}
 
开发者ID:rtr-nettest,项目名称:open-rmbt,代码行数:16,代码来源:ServerResource.java

示例3: getIP

import org.restlet.engine.header.Header; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public String getIP()
{
    final Series<Header> headers = (Series<Header>) getRequest().getAttributes().get("org.restlet.http.headers");
    final String realIp = headers.getFirstValue("X-Real-IP", true);
    if (realIp != null)
        return realIp;
    else
        return getRequest().getClientInfo().getAddress();
}
 
开发者ID:rtr-nettest,项目名称:open-rmbt,代码行数:11,代码来源:ServerResource.java

示例4: getURL

import org.restlet.engine.header.Header; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public Reference getURL()
{
    final Series<Header> headers = (Series<Header>) getRequest().getAttributes().get("org.restlet.http.headers");
    final String realURL = headers.getFirstValue("X-Real-URL", true);
    if (realURL != null)
        return new Reference(realURL);
    else
        return getRequest().getOriginalRef();
}
 
开发者ID:rtr-nettest,项目名称:open-rmbt,代码行数:11,代码来源:ServerResource.java

示例5: addAllowOrigin

import org.restlet.engine.header.Header; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected void addAllowOrigin()
{
    Series<Header> responseHeaders = (Series<Header>) getResponse().getAttributes().get("org.restlet.http.headers");
    if (responseHeaders == null)
    {
        responseHeaders = new Series<Header>(Header.class);
        getResponse().getAttributes().put("org.restlet.http.headers", responseHeaders);
    }
    responseHeaders.add("Access-Control-Allow-Origin", "*");
    responseHeaders.add("Access-Control-Allow-Methods", "GET,POST,OPTIONS");
    responseHeaders.add("Access-Control-Allow-Headers", "Content-Type");
    responseHeaders.add("Access-Control-Allow-Credentials", "false");
    responseHeaders.add("Access-Control-Max-Age", "60");
}
 
开发者ID:rtr-nettest,项目名称:open-rmbt,代码行数:16,代码来源:ServerResource.java

示例6: addCustomHeaders

import org.restlet.engine.header.Header; //导入依赖的package包/类
protected void addCustomHeaders() {
	Series<Header> responseHeaders = (Series<Header>) getResponse().getAttributes().get("org.restlet.http.headers");
	if (responseHeaders == null) {
		responseHeaders = new Series(Header.class);
		getResponse().getAttributes().put("org.restlet.http.headers", responseHeaders);
	}
	// allow request from other origins
	responseHeaders.add(new Header("Access-Control-Allow-Origin", "*"));
}
 
开发者ID:ismb,项目名称:jemma.osgi.dal.web-apis,代码行数:10,代码来源:BaseServerResource.java

示例7: doOptions

import org.restlet.engine.header.Header; //导入依赖的package包/类
@Options
public void doOptions() {
	Series<Header> responseHeaders = (Series<Header>) getResponse().getAttributes().get("org.restlet.http.headers");
	if (responseHeaders == null) {
		responseHeaders = new Series(Header.class);
		getResponse().getAttributes().put("org.restlet.http.headers", responseHeaders);
	}
	responseHeaders.add("Access-Control-Allow-Origin", "*");
	responseHeaders.add("Access-Control-Allow-Methods", "GET,POST,OPTIONS");
	responseHeaders.add("Access-Control-Allow-Headers", "Content-Type");

	responseHeaders.add("Access-Control-Max-Age", "60");
}
 
开发者ID:ismb,项目名称:jemma.osgi.dal.web-apis,代码行数:14,代码来源:BaseServerResource.java

示例8: addExtraHeaders

import org.restlet.engine.header.Header; //导入依赖的package包/类
public static void addExtraHeaders(Response response) {
  Series<Header> responseHeaders = (Series<Header>)response.getAttributes().get(HeaderConstants.ATTRIBUTE_HEADERS);
  if (responseHeaders == null) {
    responseHeaders = new Series(Header.class);
    response.getAttributes().put(HeaderConstants.ATTRIBUTE_HEADERS, responseHeaders);
  }

  responseHeaders.add(new Header(HDR_CONTROLLER_HOST, getHostName()));
  responseHeaders.add(new Header(HDR_CONTROLLER_VERSION, getControllerVersion()));
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:11,代码来源:PinotRestletResourceBase.java

示例9: getHeaders

import org.restlet.engine.header.Header; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static Series<Header> getHeaders(Response response) {
	Series<Header> headers = (Series<Header>) response.getAttributes().get("org.restlet.http.headers");
	if (headers == null) {
		headers = new Series<>(Header.class);
		response.getAttributes().put("org.restlet.http.headers", headers);
	}
	return headers;
}
 
开发者ID:ontopia,项目名称:ontopia,代码行数:10,代码来源:HeaderUtils.java

示例10: testHeaders

import org.restlet.engine.header.Header; //导入依赖的package包/类
@Test
public void testHeaders() {
	OntopiaTestResource request = new OntopiaTestResource(Method.GET, getUrl(null), defaultMediatype);
	request.request();
	Series<Header> headers = HeaderUtils.getHeaders(request.getResponse());

	Assert.assertNotNull(headers);
	Assert.assertEquals("v1", headers.getFirstValue("X-Ontopia-API-Version"));
	Assert.assertEquals("n.o.t.r.OntopiaRestApplication", headers.getFirstValue("X-Ontopia-Application"));
	Assert.assertEquals("n.o.t.r.v1.topic.TopicsResource", headers.getFirstValue("X-Ontopia-Resource"));
	Assert.assertEquals("topics.ltm", headers.getFirstValue("X-Ontopia-Topicmap"));
}
 
开发者ID:ontopia,项目名称:ontopia,代码行数:13,代码来源:HeaderTest.java

示例11: addCustomHeaders

import org.restlet.engine.header.Header; //导入依赖的package包/类
protected void addCustomHeaders()
{
	Series<Header> responseHeaders = (Series<Header>) getResponse().getAttributes().get("org.restlet.http.headers");
	if (responseHeaders == null) {
	    responseHeaders = new Series(Header.class);
	    getResponse().getAttributes().put("org.restlet.http.headers", responseHeaders);
	}
	//allow request from other origins
	responseHeaders.add(new Header("Access-Control-Allow-Origin", "*"));
}
 
开发者ID:ismb,项目名称:it.ismb.pert.osgi.dal.web-apis,代码行数:11,代码来源:BaseServerResource.java

示例12: doOptions

import org.restlet.engine.header.Header; //导入依赖的package包/类
@Options
public void doOptions()
{
	Series<Header> responseHeaders = (Series<Header>) getResponse().getAttributes().get("org.restlet.http.headers");
	if (responseHeaders == null) {
	    responseHeaders = new Series(Header.class);
	    getResponse().getAttributes().put("org.restlet.http.headers", responseHeaders);
	}
	responseHeaders.add("Access-Control-Allow-Origin", "*"); 
    responseHeaders.add("Access-Control-Allow-Methods", "GET,POST,OPTIONS");
    responseHeaders.add("Access-Control-Allow-Headers", "Content-Type"); 

    responseHeaders.add("Access-Control-Max-Age", "60"); 
}
 
开发者ID:ismb,项目名称:it.ismb.pert.osgi.dal.web-apis,代码行数:15,代码来源:BaseServerResource.java

示例13: addRestletHeader

import org.restlet.engine.header.Header; //导入依赖的package包/类
/**
 * Adds a HTTP header to a Restlet ClientResource OAUTH bearer is a pain via
 * restlet on GAE, so we set it ourselves.
 */
public static void addRestletHeader(ClientResource client, String key, String value) {
	@SuppressWarnings("unchecked")
	Series<Header> headers = (Series<Header>) client.getRequestAttributes().get("org.restlet.http.headers");
	if (headers == null) {
		headers = new Series<Header>(Header.class);
		client.getRequestAttributes().put("org.restlet.http.headers", headers);
	}
	headers.add(key, value);
}
 
开发者ID:TomDemeranville,项目名称:orcid-java-client,代码行数:14,代码来源:OrcidOAuthClient.java

示例14: getHeaderValue

import org.restlet.engine.header.Header; //导入依赖的package包/类
protected String getHeaderValue(String headerName,Request request,Series<Header> headers) {
   if (headerName.equals("Host")) {
      Reference hostRef = request.getHostRef();
      return hostRef==null ? null : hostRef.toString();
   } else {
      return headers==null ? null : headers.getFirstValue(headerName);
   }
}
 
开发者ID:alexmilowski,项目名称:xproclet,代码行数:9,代码来源:XProcHelper.java

示例15: addAccessControl

import org.restlet.engine.header.Header; //导入依赖的package包/类
protected void addAccessControl(Response response) {
   Series<Header> responseHeaders = (Series<Header>)response.getAttributes().get("org.restlet.http.headers");
   if (responseHeaders==null) {
      responseHeaders = new Series<Header>(Header.class);
      response.getAttributes().put("org.restlet.http.headers",responseHeaders);
   }
   responseHeaders.add("Access-Control-Allow-Origin", origin);
   responseHeaders.add("Access-Control-Allow-Headers",allowHeaders);
}
 
开发者ID:alexmilowski,项目名称:xproclet,代码行数:10,代码来源:CORSFilter.java


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