本文整理了Java中org.mortbay.jetty.HttpConnection
类的一些代码示例,展示了HttpConnection
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpConnection
类的具体详情如下:
包路径:org.mortbay.jetty.HttpConnection
类名称:HttpConnection
[英]A HttpConnection represents the connection of a HTTP client to the server and is created by an instance of a Connector. It's prime function is to associate Request and Response instances with a EndPoint.
A connection is also the prime mechanism used by jetty to recycle objects without pooling. The Request, Response, HttpParser, HttpGeneratorand HttpFields instances are all recycled for the duraction of a connection. Where appropriate, allocated buffers are also kept associated with the connection via the parser and/or generator.
[中]HttpConnection表示HTTP客户端到服务器的连接,由连接器实例创建。它的主要功能是将请求和响应实例与端点相关联。
连接也是jetty用于无池回收对象的主要机制。请求、响应、HttpParser、HttpGenerator和HttpFields实例都在连接期间循环使用。在适当的情况下,分配的缓冲区还通过解析器和/或生成器与连接保持关联。
代码示例来源:origin: twitter/ambrose
private static void setHandled(HttpServletRequest request) {
Request base_request = (request instanceof Request) ?
(Request) request : HttpConnection.getCurrentConnection().getRequest();
base_request.setHandled(true);
}
代码示例来源:origin: org.mortbay.jetty/com.springsource.org.mortbay.jetty.server
public void handle(String target, HttpServletRequest request, HttpServletResponse response, int dispatch) throws IOException, ServletException
Request base_request = (request instanceof Request) ? (Request)request:HttpConnection.getCurrentConnection().getRequest();
Response base_response = (response instanceof Response) ? (Response)response:HttpConnection.getCurrentConnection().getResponse();
UserRealm old_realm = base_request.getUserRealm();
try
base_request.setUserRealm(getUserRealm());
if (dispatch==REQUEST && !checkSecurityConstraints(target,base_request,base_response))
base_request.setHandled(true);
return;
代码示例来源:origin: org.mortbay.jetty/com.springsource.org.mortbay.jetty.server
Request base_request=(request instanceof Request)?(Request)request:HttpConnection.getCurrentConnection().getRequest();
Response base_response=(response instanceof Response)?(Response)response:HttpConnection.getCurrentConnection().getResponse();
base_request.setHandled(true);
return;
base_request.setHandled(true);
return;
base_request.setHandled(true);
return;
代码示例来源:origin: org.mortbay.jetty/com.springsource.org.mortbay.jetty.server
Thread current_thread=null;
Request base_request=(request instanceof Request)?(Request)request:HttpConnection.getCurrentConnection().getRequest();
if( !isStarted() || _shutdown || (dispatch==REQUEST && base_request.isHandled()))
return;
old_context=base_request.getContext();
String connector=HttpConnection.getCurrentConnection().getConnector().getName();
if (connector==null || !_connectors.contains(connector))
return;
base_request.setHandled(true);
if (request.getQueryString()!=null)
response.sendRedirect(URIUtil.addPaths(request.getRequestURI(),URIUtil.SLASH)+"?"+request.getQueryString());
代码示例来源:origin: org.mortbay.jetty/com.springsource.org.mortbay.jetty.server
public void handle(String target, HttpServletRequest request, HttpServletResponse response, int dispatch) throws IOException, ServletException
Request base_request = request instanceof Request?(Request)request:HttpConnection.getCurrentConnection().getRequest();
if (base_request.isHandled() || !request.getMethod().equals(HttpMethods.GET))
return;
base_request.setHandled(true);
代码示例来源:origin: org.mortbay.jetty/com.springsource.org.mortbay.jetty.server
final Request base_request=(request instanceof Request)?((Request)request):HttpConnection.getCurrentConnection().getRequest();
final String old_servlet_name=base_request.getServletName();
final String old_servlet_path=base_request.getServletPath();
final String old_path_info=base_request.getPathInfo();
final Map old_role_map=base_request.getRoleMap();
代码示例来源:origin: org.mortbay.jetty/com.springsource.org.mortbay.jetty.server
public void handle(String target, HttpServletRequest request, HttpServletResponse response, int dispatch) throws IOException
{
HttpConnection.getCurrentConnection().getRequest().setHandled(true);
response.setContentType(MimeTypes.TEXT_HTML_8859_1);
ByteArrayISO8859Writer writer= new ByteArrayISO8859Writer(4096);
HttpConnection connection = HttpConnection.getCurrentConnection();
handleErrorPage(request, writer, connection.getResponse().getStatus(), connection.getResponse().getReason());
writer.flush();
response.setContentLength(writer.size());
writer.writeTo(response.getOutputStream());
writer.destroy();
}
代码示例来源:origin: org.mortbay.jetty/com.springsource.org.mortbay.jetty.server
protected void forward(ServletRequest request, ServletResponse response, int dispatch) throws ServletException, IOException
Request base_request=(request instanceof Request)?((Request)request):HttpConnection.getCurrentConnection().getRequest();
response.resetBuffer();
String old_uri=base_request.getRequestURI();
String old_context_path=base_request.getContextPath();
String old_servlet_path=base_request.getServletPath();
String old_path_info=base_request.getPathInfo();
String old_query=base_request.getQueryString();
if (base_request.getConnection().getResponse().isWriting())
代码示例来源:origin: org.graniteds/granite-server
public Principal login(Object credentials, String charset) throws SecurityServiceException {
String[] decoded = decodeBase64Credentials(credentials, charset);
HttpGraniteContext graniteContext = (HttpGraniteContext)GraniteContext.getCurrentInstance();
HttpServletRequest httpRequest = graniteContext.getRequest();
Request request = httpRequest instanceof Request ? (Request)httpRequest : HttpConnection.getCurrentConnection().getRequest();
UserRealm realm = request.getUserRealm();
Principal principal = realm.authenticate(decoded[0], decoded[1], request);
if (principal == null) {
if (request.getSession(false) != null)
request.getSession(false).removeAttribute(JETTY6_AUTH);
throw SecurityServiceException.newInvalidCredentialsException("Wrong username or password");
}
request.setAuthType(AUTH_TYPE);
request.setUserPrincipal(principal);
request.getSession().setAttribute(JETTY6_AUTH, principal);
endLogin(credentials, charset);
return principal;
}
代码示例来源:origin: org.mortbay.jetty/jetty-security
HttpConnection connection = HttpConnection.getCurrentConnection();
Connector connector = connection.getConnector();
connector.getIntegralScheme()
+ "://"
+ request.getServerName()
+ ":"
+ connector.getIntegralPort()
+ request.getRequestURI();
if (request.getQueryString() != null)
url += "?" + request.getQueryString();
response.setContentLength(0);
代码示例来源:origin: org.mortbay.jetty/com.springsource.org.mortbay.jetty.server
public void handle(String target, HttpServletRequest request, HttpServletResponse response, int dispatch) throws IOException, ServletException
final Request base_request=(request instanceof Request)?((Request)request):HttpConnection.getCurrentConnection().getRequest();
final Response base_response=(response instanceof Response)?((Response)response):HttpConnection.getCurrentConnection().getResponse();
_requestsActiveMin=_requestsActive;
long duration = System.currentTimeMillis()-base_request.getTimeStamp();
代码示例来源:origin: org.mortbay.jetty/com.springsource.org.mortbay.jetty.server
public void include(ServletRequest request, ServletResponse response) throws ServletException, IOException
Request base_request=(request instanceof Request)?((Request)request):HttpConnection.getCurrentConnection().getRequest();
Attributes old_attr=base_request.getAttributes();
MultiMap old_params=base_request.getParameters();
try
base_request.getConnection().include();
if (_named!=null)
_contextHandler.handle(_named, (HttpServletRequest)request, (HttpServletResponse)response, Handler.INCLUDE);
base_request.setAttributes(old_attr);
base_request.getConnection().included();
base_request.setParameters(old_params);
代码示例来源:origin: org.mortbay.jetty/com.springsource.org.mortbay.jetty.server
Request base_request = (request instanceof Request) ? (Request)request:HttpConnection.getCurrentConnection().getRequest();
SessionManager old_session_manager=null;
HttpSession old_session=null;
old_session_manager = base_request.getSessionManager();
old_session = base_request.getSession(false);
base_request.setSessionManager(_sessionManager);
base_request.setSession(null);
代码示例来源:origin: org.mortbay.jetty/com.springsource.org.mortbay.jetty.server
public void handle(String target, HttpServletRequest request, HttpServletResponse response, int dispatch)
throws IOException, ServletException
{
Handler[] handlers = getHandlers();
if (handlers!=null && isStarted())
{
Request base_request = HttpConnection.getCurrentConnection().getRequest();
for (int i=0;i<handlers.length;i++)
{
handlers[i].handle(target,request, response, dispatch);
if ( base_request.isHandled())
return;
}
}
}
}
代码示例来源:origin: stevensouza/jamonapi
/** Monitor the request and call any other requests in the decorator chain */
@Override
public void handle(String target, HttpServletRequest request, HttpServletResponse response, int dispatch) throws IOException, ServletException {
final Request baseRequest = (request instanceof Request) ? ((Request)request) : HttpConnection.getCurrentConnection().getRequest();
final Response baseResponse = (response instanceof Response) ? ((Response)response) : HttpConnection.getCurrentConnection().getResponse();
HttpMon httpMon=null;
try {
httpMon=httpMonFactory.start(baseRequest, baseResponse);
super.handle(target, request, response, dispatch);
} catch (Throwable e) {
httpMon.throwException(e);
} finally {
httpMon.stop();
}
}
代码示例来源:origin: org.graniteds/granite-server
public void logout() throws SecurityServiceException {
HttpGraniteContext graniteContext = (HttpGraniteContext)GraniteContext.getCurrentInstance();
HttpServletRequest httpRequest = graniteContext.getRequest();
Request request = httpRequest instanceof Request ? (Request)httpRequest : HttpConnection.getCurrentConnection().getRequest();
UserRealm realm = request.getUserRealm();
realm.disassociate(httpRequest.getUserPrincipal());
endLogout();
}
代码示例来源:origin: org.mortbay.jetty/com.springsource.org.mortbay.jetty.server
base_request=HttpConnection.getCurrentConnection().getRequest();
user=_realm.pushRole(base_request.getUserPrincipal(),_runAs);
base_request.setUserPrincipal(user);
base_request.setUserPrincipal(user);
代码示例来源:origin: org.mortbay.jetty/com.springsource.org.mortbay.jetty.server
public static Request getRequest(HttpServletRequest request)
{
if (request instanceof Request)
return (Request) request;
while (request instanceof ServletRequestWrapper)
request = (HttpServletRequest)((ServletRequestWrapper)request).getRequest();
if (request instanceof Request)
return (Request) request;
return HttpConnection.getCurrentConnection().getRequest();
}
代码示例来源:origin: org.jboss.errai/errai-cdi-jetty
if ("/favicon.ico".equals(request.getRequestURI())
&& request.getQueryString() == null) {
String userString = request.getRemoteUser();
if (userString == null) {
userString = "";
Iterator<Field> headerFields = request.getConnection().getRequestFields().getFields();
while (headerFields.hasNext()) {
Field headerField = headerFields.next();
代码示例来源:origin: org.mortbay.jetty/com.springsource.org.mortbay.jetty.server
HttpFields response_fields=_connection.getResponseFields();
response_fields.clear();
String connection=_connection.getRequestFields().getStringField(HttpHeaders.CONNECTION_BUFFER);
if (connection!=null)
if (HttpVersions.HTTP_1_0.equalsIgnoreCase(_connection.getRequest().getProtocol()))
response_fields.put(HttpHeaders.CONNECTION_BUFFER,HttpHeaderValues.KEEP_ALIVE);
break;
if (_connection.getConnector().getServer().getSendDateHeader())
Request request=_connection.getRequest();
response_fields.put(HttpHeaders.DATE_BUFFER, request.getTimeStampBuffer(),request.getTimeStamp());
内容来源于网络,如有侵权,请联系作者删除!