本文整理了Java中org.mortbay.jetty.Request
类的一些代码示例,展示了Request
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request
类的具体详情如下:
包路径:org.mortbay.jetty.Request
类名称:Request
[英]Jetty Request.
Implements javax.servlet.HttpServletRequest from the javax.servlet package.
The standard interface of mostly getters, is extended with setters so that the request is mutable by the handlers that it is passed to. This allows the request object to be as lightweight as possible and not actually implement any significant behaviour. For example
代码示例来源:origin: Netflix/eureka
protected void sendOkResponseWithContent(Request request, HttpServletResponse response, Applications apps)
throws IOException {
String content = XmlXStream.getInstance().toXML(apps);
response.setContentType("application/xml");
response.setStatus(HttpServletResponse.SC_OK);
response.getWriter().println(content);
response.getWriter().flush();
request.setHandled(true);
System.out.println("Eureka port: " + port + ". " + System.currentTimeMillis() +
". Eureka resource mock, sent response for request path: " + request.getPathInfo() +
", apps count: " + apps.getRegisteredApplications().size());
}
代码示例来源:origin: Netflix/eureka
private void sendOkResponseWithContent(Request request, HttpServletResponse response, String content)
throws IOException {
response.setContentType("application/json; charset=UTF-8");
response.setStatus(HttpServletResponse.SC_OK);
response.getOutputStream().write(content.getBytes("UTF-8"));
response.getOutputStream().flush();
request.setHandled(true);
System.out.println("Eureka resource mock, sent response for request path: " + request.getPathInfo() +
" with content" + content);
}
}
代码示例来源:origin: org.mortbay.jetty/jetty-embedded
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();
base_request.setHandled(true);
response.setContentType("text/html");
response.setStatus(HttpServletResponse.SC_OK);
response.getWriter().println("<h1>Hello OneHandler</h1>");
}
}
代码示例来源: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);
if (!request.getPathInfo().endsWith(URIUtil.SLASH))
response.sendRedirect(URIUtil.addPaths(request.getRequestURI(),URIUtil.SLASH));
return;
response.sendError(HttpServletResponse.SC_FORBIDDEN);
return;
if (if_modified>0 && last_modified/1000<=if_modified/1000)
response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
return;
代码示例来源: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 (response.isCommitted() || base_request.isHandled())
return;
base_request.setHandled(true);
String method=request.getMethod();
if (_serveIcon && _favicon!=null && method.equals(HttpMethods.GET) && request.getRequestURI().equals("/favicon.ico"))
if (request.getDateHeader(HttpHeaders.IF_MODIFIED_SINCE)==_faviconModified)
response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
else
response.setStatus(HttpServletResponse.SC_OK);
response.setContentType("image/x-icon");
response.setContentLength(_favicon.length);
代码示例来源:origin: org.mortbay.jetty/jetty-security
log.debug("HTAccessHandler pathInContext="+pathInContext,null,null);
String credentials=request.getHeader(HttpHeaders.AUTHORIZATION);
response.sendError(HttpServletResponse.SC_FORBIDDEN);
base_request.setHandled(true);
return;
response.sendError(HttpServletResponse.SC_FORBIDDEN);
base_request.setHandled(true);
return;
response.sendError(HttpServletResponse.SC_FORBIDDEN);
base_request.setHandled(true);
return;
response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
base_response.complete();
base_request.setHandled(true);
return;
base_request.setAuthType(Constraint.__BASIC_AUTH);
base_request.setUserPrincipal(getPrincipal(user, getUserRealm()));
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
base_request.setHandled(true);
代码示例来源:origin: org.paxml/PaxmlSelenium
res.setStatus(HttpServletResponse.SC_OK);
res.setContentType("binary/x-paxml");
res.setHeader("Content-Disposition", "attachment; filename=\"" + path +"\"");
res.setHeader("Pragma", "");
res.setHeader("Cache-control", "");
IOUtils.copy(in, res.getOutputStream());
((Request) request).setHandled(true);
代码示例来源:origin: org.sonatype.plexus/plexus-jetty6
( request instanceof Request ) ? (Request) request : HttpConnection.getCurrentConnection().getRequest();
base_request.setHandled( true );
Writer writer = new OutputStreamWriter( buf, StringUtil.__ISO_8859_1 );
writer.write( "Request Dump from:" + label );
writer.write( "\npathInfo=" + request.getPathInfo() + "\n\n" );
writer.write( "Header:\n" );
writer.write( request.toString() );
writer.write( "\n\nParameters:\n" );
Enumeration names = request.getParameterNames();
while ( names.hasMoreElements() )
String[] values = request.getParameterValues( name );
if ( values == null || values.length == 0 )
代码示例来源:origin: telefonicaid/fiware-cygnus
@Override
public void handle(String target, HttpServletRequest request, HttpServletResponse response, int dispatch)
throws IOException, ServletException {
HttpConnection connection = HttpConnection.getCurrentConnection();
Request baseRequest = (request instanceof Request) ? (Request) request : connection.getRequest();
baseRequest.setHandled(true);
response.setContentType("text/html;charset=utf-8");
int port = request.getLocalPort();
String uri = request.getRequestURI();
String method = request.getMethod();
LOGGER.info("Management interface request. Method: " + method + ", URI: " + uri);
NameMappingsHandlers.get(request, response, nameMappingsConfFile);
} else {
response.setStatus(HttpServletResponse.SC_NOT_IMPLEMENTED);
response.getWriter().println(method + " " + uri + " not implemented");
代码示例来源:origin: aseldawy/spatialhadoop2
ServletException {
response.addHeader("Access-Control-Allow-Origin", "*");
response.addHeader("Access-Control-Allow-Credentials", "true");
((Request) request).setHandled(true);
LOG.info("Received request: '"+request.getRequestURL()+"'");
if (target.endsWith("/generate_image.cgi")) {
LOG.info("Generating image");
response.setStatus(HttpServletResponse.SC_OK);
response.setContentType("text/plain;charset=utf-8");
response.getWriter().println("Image request received successfully");
代码示例来源:origin: org.mortbay.jetty/com.springsource.org.mortbay.jetty.server
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();
base_request.setHandled(true);
if (request.getQueryString()!=null)
response.sendRedirect(URIUtil.addPaths(request.getRequestURI(),URIUtil.SLASH)+"?"+request.getQueryString());
else
response.sendRedirect(URIUtil.addPaths(request.getRequestURI(),URIUtil.SLASH));
return;
old_context_path=base_request.getContextPath();
old_servlet_path=base_request.getServletPath();
old_path_info=base_request.getPathInfo();
base_request.setContext(_scontext);
if (dispatch!=INCLUDE && target.startsWith("/"))
base_request.setContextPath("");
else
base_request.setContextPath(_contextPath);
base_request.setServletPath(null);
base_request.setPathInfo(target);
base_request.addEventListener(((EventListener)LazyList.get(_requestAttributeListeners,i)));
base_request.removeEventListener(((EventListener)LazyList.get(_requestAttributeListeners,i)));
代码示例来源:origin: tcplugins/tcWebHooks
@Override
public void service(ServletRequest req, ServletResponse res)
throws ServletException, IOException {
System.out.println("Handling Proxy request for " + ((Request) req).getUri().toString());
if ( authRequired )
String proxyAuthorization = request.getHeader( "Proxy-Authorization" );
if ( proxyAuthorization != null && proxyAuthorization.startsWith( "Basic " ) )
response.addHeader( "Proxy-Authenticate", "Basic realm=\"Jetty Proxy Authorization\"" );
response.setStatus( HttpServletResponse.SC_PROXY_AUTHENTICATION_REQUIRED );
System.out.println("Proxy Auth Creds not supplied");
代码示例来源:origin: org.mortbay.jetty/com.springsource.org.mortbay.jetty.server
public void handle(String target, HttpServletRequest request, HttpServletResponse response, int dispatch) throws IOException, ServletException
{
if (_newContextURL==null)
return;
Request base_request=(request instanceof Request)?(Request)request:HttpConnection.getCurrentConnection().getRequest();
String url = _newContextURL;
if (!_discardPathInfo && request.getPathInfo()!=null)
url=URIUtil.addPaths(url, request.getPathInfo());
if (!_discardQuery && request.getQueryString()!=null)
url+="?"+request.getQueryString();
response.sendRedirect(url);
if (_permanent)
response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
base_request.setHandled(true);
}
代码示例来源:origin: org.motechproject/motech-testing-utils
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
requests.put(request.getContextPath(), collectRequestInfo(request));
response.setStatus(HttpServletResponse.SC_OK);
response.getWriter().write(OK);
Request baseRequest = (Request) request;
baseRequest.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();
base_request.setServletName(servlet_holder.getName());
base_request.setRoleMap(servlet_holder.getRoleMap());
if(Log.isDebugEnabled())Log.debug("servlet="+servlet_holder);
base_request.setAttribute(Dispatcher.__INCLUDE_SERVLET_PATH,servlet_path);
base_request.setAttribute(Dispatcher.__INCLUDE_PATH_INFO, path_info);
base_request.setServletPath(servlet_path);
base_request.setPathInfo(path_info);
base_request.setServletName(servlet_holder.getName());
chain=getFilterChain(type, null,servlet_holder);
base_request.setHandled(true);
if (chain!=null)
chain.doFilter(request, response);
base_request.setHandled(false);
throw e;
base_request.setServletName(old_servlet_name);
base_request.setRoleMap(old_role_map);
if (type!=INCLUDE)
代码示例来源: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: pentaho/pentaho-kettle
public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch )
throws IOException, ServletException {
if ( target.contains( "/Callback" ) ) {
CustomLocalServerReceiver.this.error = request.getParameter( "error" );
if ( CustomLocalServerReceiver.this.code == null ) {
CustomLocalServerReceiver.this.code = request.getParameter( "code" );
}
if ( CustomLocalServerReceiver.this.url != null && CustomLocalServerReceiver.this.error != null
&& CustomLocalServerReceiver.this.error.equals( "access_denied" ) ) {
response.sendRedirect( CustomLocalServerReceiver.this.url );
} else {
super.handle( target, request, response, dispatch );
}
( (Request) request ).setHandled( true );
}
}
}
代码示例来源:origin: jpotts/alfresco-api-java-examples
@Override
public void handle(
String target, HttpServletRequest request, HttpServletResponse response, int dispatch)
throws IOException {
if (!CALLBACK_PATH.equals(target)) {
return;
}
writeLandingHtml(response);
response.flushBuffer();
((Request) request).setHandled(true);
String error = request.getParameter("error");
if (error != null) {
System.out.println("Authorization failed. Error=" + error);
System.out.println("Quitting.");
System.exit(1);
}
code = request.getParameter("code");
synchronized (LocalServerReceiver.this) {
LocalServerReceiver.this.notify();
}
}
代码示例来源:origin: aseldawy/spatialhadoop2
public void handle(String target, HttpServletRequest request, HttpServletResponse response, int dispatch)
throws IOException, ServletException {
// Bypass cross-site scripting (XSS)
response.addHeader("Access-Control-Allow-Origin", "*");
response.addHeader("Access-Control-Allow-Credentials", "true");
((Request) request).setHandled(true);
try {
if (target.startsWith("/dynamic/showImage.cgi")) {
displayImage(target, response);
} else {
LOG.info("Received request: '"+request.getRequestURL()+"'");
tryToLoadStaticResource(target, response);
}
} catch (Exception e) {
e.printStackTrace();
//reportError(response, "Error placing the request", e);
}
}
代码示例来源:origin: aseldawy/spatialhadoop2
((Request) request).setHandled(true);
LOG.info("Received request: '" + request.getRequestURL() + "'");
if (target.startsWith("/hdfs/") && request.getMethod().equals("GET")) {
handleHDFSFetch(request, response);
} else if (target.endsWith("/LISTSTATUS.cgi") && request.getMethod().equals("GET")){
handleListFiles(request, response);
} else if (target.endsWith("/VISUALIZE.cgi") && request.getMethod().equals("POST")){
内容来源于网络,如有侵权,请联系作者删除!