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


Java HttpHeaders.getHeaderString方法代码示例

本文整理汇总了Java中javax.ws.rs.core.HttpHeaders.getHeaderString方法的典型用法代码示例。如果您正苦于以下问题:Java HttpHeaders.getHeaderString方法的具体用法?Java HttpHeaders.getHeaderString怎么用?Java HttpHeaders.getHeaderString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.ws.rs.core.HttpHeaders的用法示例。


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

示例1: AuthorizationService

import javax.ws.rs.core.HttpHeaders; //导入方法依赖的package包/类
public AuthorizationService(@Context HttpHeaders headers) {
    authorization = false;

    String token = headers.getHeaderString("Authorization");
    if (token != null) {
        try {
            Session session = HibernateUtil.getSessionFactory().openSession();

            CriteriaBuilder builder = session.getCriteriaBuilder();

            CriteriaQuery<User> criteria = builder.createQuery(User.class);
            Root<User> root = criteria.from(User.class);
            criteria.select(root);
            criteria.where(builder.equal(root.get(User_.token), token));

            authenticate = session.createQuery(criteria).getSingleResult();

            if (authenticate != null)
                authorization = true;
        } catch (Exception e) {
        }
    }
}
 
开发者ID:YMonnier,项目名称:docker-restful-java,代码行数:24,代码来源:AuthorizationService.java

示例2: getCorrelationId

import javax.ws.rs.core.HttpHeaders; //导入方法依赖的package包/类
@Override
public String getCorrelationId() {
  HttpHeaders headers = ResteasyProviderFactory.getContextData(HttpHeaders.class);

  String correlationId;
  if (headers != null) {
    correlationId = headers.getHeaderString(headerName);
    if (correlationId != null) {
      return correlationId;
    }
  }

  // Fall back to MDC to support beadledom-jaxrs 1.0. Retrieving from the headers is preferred.
  correlationId = MDC.get(mdcName);

  return correlationId;
}
 
开发者ID:cerner,项目名称:beadledom,代码行数:18,代码来源:ResteasyCorrelationIdContext.java

示例3: toExternalURI

import javax.ws.rs.core.HttpHeaders; //导入方法依赖的package包/类
private URI toExternalURI(final URI uri, final HttpHeaders headers) {
    final String host = headers.getHeaderString("Host");
    final String protocol = headers.getHeaderString("X-Forwarded-Proto");
    final String context = headers.getHeaderString("context");
    return URI.create(protocol + "://" + host + "/" + context + uri.getPath());
}
 
开发者ID:duraspace,项目名称:lambdora,代码行数:7,代码来源:LambdoraLdp.java

示例4: downloadFile

import javax.ws.rs.core.HttpHeaders; //导入方法依赖的package包/类
/**
 * Respond with the binary data
 * 
 * @param stagingUuid
 * @param filename
 * @return
 */
@Override
public Response downloadFile(HttpHeaders headers, String stagingUuid, String filepath)
{
	final StagingFile stagingFile = getStagingFile(stagingUuid);
	ensureFileExists(stagingFile, filepath);

	try
	{
		final String etag = headers.getHeaderString(HttpHeaders.IF_NONE_MATCH);
		if( etag != null )
		{
			String md5Checksum = fileSystemService.getMD5Checksum(stagingFile, filepath);
			String quotedChecksum = "\"" + md5Checksum + "\"";
			if( Objects.equals(etag, quotedChecksum) )
			{
				return Response.notModified(quotedChecksum).build();
			}
		}
		final String modifiedSince = headers.getHeaderString(HttpHeaders.IF_MODIFIED_SINCE);
		if( modifiedSince != null )
		{
			final Date lastModified = new Date(fileSystemService.lastModified(stagingFile, filepath));
			if( Objects.equals(modifiedSince, DateUtil.formatDate(lastModified)) )
			{
				return Response.notModified().build();
			}
		}

		final InputStream input = fileSystemService.read(stagingFile, filepath);

		final String mimeType = mimeService.getMimeTypeForFilename(filepath);
		return Response.ok().type(mimeType).entity(new StreamingOutput()
		{
			@Override
			public void write(OutputStream output) throws IOException, WebApplicationException
			{
				try
				{
					ByteStreams.copy(input, output);
				}
				finally
				{
					Closeables.close(input, false);
				}
			}
		}).build();
	}
	catch( IOException e )
	{
		throw Throwables.propagate(e);
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:60,代码来源:FileResourceImpl.java

示例5: getFile

import javax.ws.rs.core.HttpHeaders; //导入方法依赖的package包/类
@Override
public Response getFile(HttpHeaders headers, String uuid, String filepath)
{
	final StagingFile stagingFile = getStagingFile(uuid);
	ensureFileExists(stagingFile, filepath);

	try
	{
		final String etag = headers.getHeaderString(HttpHeaders.IF_NONE_MATCH);
		if( etag != null )
		{
			String md5Checksum = fileSystemService.getMD5Checksum(stagingFile, filepath);
			String quotedChecksum = "\"" + md5Checksum + "\"";
			if( Objects.equals(etag, quotedChecksum) )
			{
				return Response.notModified(quotedChecksum).build();
			}
		}
		final String modifiedSince = headers.getHeaderString(HttpHeaders.IF_MODIFIED_SINCE);
		if( modifiedSince != null )
		{
			final Date lastModified = new Date(fileSystemService.lastModified(stagingFile, filepath));
			if( Objects.equals(modifiedSince, DateUtil.formatDate(lastModified)) )
			{
				return Response.notModified().build();
			}
		}

		final InputStream input = fileSystemService.read(stagingFile, filepath);
		final ResponseBuilder responseBuilder = makeResponseHeaders(uuid, filepath);
		return responseBuilder.entity(new StreamingOutput()
		{
			@Override
			public void write(OutputStream output) throws IOException, WebApplicationException
			{
				try
				{
					ByteStreams.copy(input, output);
				}
				finally
				{
					Closeables.close(input, false);
				}
			}
		}).build();
	}
	catch( IOException e )
	{
		throw Throwables.propagate(e);
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:52,代码来源:StagingResourceImpl.java


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