本文整理了Java中org.eclipse.jetty.server.Response.getHttpFields
方法的一些代码示例,展示了Response.getHttpFields
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Response.getHttpFields
方法的具体详情如下:
包路径:org.eclipse.jetty.server.Response
类名称:Response
方法名:getHttpFields
暂无
代码示例来源:origin: spring-projects/spring-framework
private static HttpHeaders createHeaders(HttpServletResponse response) {
HttpFields fields = ((Response) response).getHttpFields();
return new HttpHeaders(new JettyHeadersAdapter(fields));
}
代码示例来源:origin: neo4j/neo4j
private static void addResponseFieldIfConfigured( Request request, HttpField field )
{
if ( field != null )
{
request.getResponse().getHttpFields().add( field );
}
}
代码示例来源:origin: org.springframework/spring-web
private static HttpHeaders createHeaders(HttpServletResponse response) {
HttpFields fields = ((Response) response).getHttpFields();
return new HttpHeaders(new JettyHeadersAdapter(fields));
}
代码示例来源:origin: loklak/loklak_server
public static void setCaching(final HttpServletResponse response, final int expiresSeconds) {
if (response instanceof org.eclipse.jetty.server.Response) {
org.eclipse.jetty.server.Response r = (org.eclipse.jetty.server.Response) response;
HttpFields fields = r.getHttpFields();
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldNotAddHstsHeaderWhenNotConfigured()
{
Customizer customizer = newCustomizer();
Request request = newRequest();
customize( customizer, request );
String hstsValue = request.getResponse().getHttpFields().get( STRICT_TRANSPORT_SECURITY );
assertNull( hstsValue );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldAddHstsHeaderWhenConfigured()
{
String configuredValue = "max-age=3600; includeSubDomains";
Customizer customizer = newCustomizer( configuredValue );
Request request = newRequest();
customize( customizer, request );
String receivedValue = request.getResponse().getHttpFields().get( STRICT_TRANSPORT_SECURITY );
assertEquals( configuredValue, receivedValue );
}
代码示例来源:origin: yacy/yacy_grid_mcp
public static void setCaching(final HttpServletResponse response, final int expiresSeconds) {
if (response instanceof org.eclipse.jetty.server.Response) {
org.eclipse.jetty.server.Response r = (org.eclipse.jetty.server.Response) response;
HttpFields fields = r.getHttpFields();
代码示例来源:origin: com.madgag/org.eclipse.jgit.junit.http
private static Map<String, String> cloneHeaders(final Response rsp) {
Map<String, String> r = new TreeMap<String, String>();
Enumeration<String> hn = rsp.getHttpFields().getFieldNames();
while (hn.hasMoreElements()) {
String key = hn.nextElement();
if (!r.containsKey(key)) {
Enumeration<String> v = rsp.getHttpFields().getValues(key);
r.put(key, v.nextElement());
}
}
return Collections.unmodifiableMap(r);
}
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit.junit.http
private static Map<String, String> cloneHeaders(Response rsp) {
Map<String, String> r = new TreeMap<>();
Enumeration<String> hn = rsp.getHttpFields().getFieldNames();
while (hn.hasMoreElements()) {
String key = hn.nextElement();
if (!r.containsKey(key)) {
Enumeration<String> v = rsp.getHttpFields().getValues(key);
r.put(key, v.nextElement());
}
}
return Collections.unmodifiableMap(r);
}
代码示例来源:origin: ch.qos.logback/logback-access
@Override
public Map<String, String> buildResponseHeaderMap() {
Map<String, String> responseHeaderMap = new HashMap<String, String>();
HttpFields httpFields = response.getHttpFields();
Enumeration e = httpFields.getFieldNames();
while (e.hasMoreElements()) {
String key = (String) e.nextElement();
String value = response.getHeader(key);
responseHeaderMap.put(key, value);
}
return responseHeaderMap;
}
代码示例来源:origin: com.yahoo.vespa/jdisc_http_service
@Override
public void removeHeaders(String name) {
HttpServletResponse parentResponse = parent.getResponse();
if (parentResponse instanceof org.eclipse.jetty.server.Response) {
org.eclipse.jetty.server.Response jettyResponse = (org.eclipse.jetty.server.Response)parentResponse;
jettyResponse.getHttpFields().remove(name);
} else {
throw new UnsupportedOperationException(
"Cannot remove headers for response of type " + parentResponse.getClass().getName());
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-web
private static HttpHeaders createHeaders(HttpServletResponse response) {
HttpFields fields = ((Response) response).getHttpFields();
return new HttpHeaders(new JettyHeadersAdapter(fields));
}
代码示例来源:origin: org.neo4j.app/neo4j-server
private static void addResponseFieldIfConfigured( Request request, HttpField field )
{
if ( field != null )
{
request.getResponse().getHttpFields().add( field );
}
}
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.jetty.server
/**
* Customizes the request attributes for general secure settings.
* The default impl calls {@link Request#setSecure(boolean)} with true
* and sets a response header if the Strict-Transport-Security options
* are set.
* @param request the request being customized
*/
protected void customizeSecure(Request request)
{
request.setSecure(true);
if (_stsField!=null)
request.getResponse().getHttpFields().add(_stsField);
}
代码示例来源:origin: jenkinsci/winstone
/**
* Customizes the request attributes for general secure settings.
* The default impl calls {@link Request#setSecure(boolean)} with true
* and sets a response header if the Strict-Transport-Security options
* are set.
* @param request the request being customized
*/
protected void customizeSecure(Request request)
{
request.setSecure(true);
if (_stsField!=null)
request.getResponse().getHttpFields().add(_stsField);
}
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.jetty.server
public void onRequest(MetaData.Request request)
{
_requests.incrementAndGet();
_request.setTimeStamp(System.currentTimeMillis());
HttpFields fields = _response.getHttpFields();
if (_configuration.getSendDateHeader() && !fields.contains(HttpHeader.DATE))
fields.put(_connector.getServer().getDateField());
_request.setMetaData(request);
}
代码示例来源:origin: com.ovea.tajin.servers/tajin-server-jetty9
protected void handleOptions(Request request,Response response) throws IOException
{
if (!HttpMethod.OPTIONS.is(request.getMethod()))
response.sendError(HttpStatus.BAD_REQUEST_400);
request.setHandled(true);
response.setStatus(200);
response.getHttpFields().put(HttpHeader.ALLOW,"GET,POST,HEAD,OPTIONS");
response.setContentLength(0);
response.complete();
}
代码示例来源:origin: com.ovea.tajin.server/tajin-server-jetty9
protected void handleOptions(Request request,Response response) throws IOException
{
if (!HttpMethod.OPTIONS.is(request.getMethod()))
response.sendError(HttpStatus.BAD_REQUEST_400);
request.setHandled(true);
response.setStatus(200);
response.getHttpFields().put(HttpHeader.ALLOW,"GET,POST,HEAD,OPTIONS");
response.setContentLength(0);
response.complete();
}
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.jetty.server
@Override
public void onComplete(AsyncEvent event) throws IOException
{
AsyncContextEvent ace=(AsyncContextEvent)event;
String cname=findContextName(ace.getServletContext());
String rname=findRequestName(ace.getAsyncContext().getRequest());
Request br=Request.getBaseRequest(ace.getAsyncContext().getRequest());
Response response = br.getResponse();
String headers=_showHeaders?("\n"+response.getHttpFields().toString()):"";
log("! ctx=%s r=%s onComplete %s %d%s",cname,rname,ace.getHttpChannelState(),response.getStatus(),headers);
}
};
代码示例来源:origin: jenkinsci/winstone
@Override
public void onComplete(AsyncEvent event) throws IOException
{
AsyncContextEvent ace=(AsyncContextEvent)event;
String cname=findContextName(ace.getServletContext());
String rname=findRequestName(ace.getAsyncContext().getRequest());
Request br=Request.getBaseRequest(ace.getAsyncContext().getRequest());
Response response = br.getResponse();
String headers=_showHeaders?("\n"+response.getHttpFields().toString()):"";
log("! ctx=%s r=%s onComplete %s %d%s",cname,rname,ace.getHttpChannelState(),response.getStatus(),headers);
}
};
内容来源于网络,如有侵权,请联系作者删除!