Refine search
/** * Return the request URI for this request. */ public String getRequestURI() { return request.requestURI().toString(); }
/** * Return the server name responding to this Request. */ public String getServerName() { return (request.serverName().toString()); }
/** * Return the first value of the specified header, if any; otherwise, * return <code>null</code> * * @param name Name of the requested header */ public String getHeader(String name) { return request.getHeader(name); }
/** * Returns the Internet Protocol (IP) port number of the interface * on which the request was received. */ public int getLocalPort(){ if (localPort == -1){ if (socket != null) { localPort = socket.getLocalPort(); } else { request.action (ActionCode.ACTION_REQ_LOCALPORT_ATTRIBUTE, request); localPort = request.getLocalPort(); } } return localPort; }
MessageBytes methodMB = request.method(); if (methodMB.equals(Constants.GET)) { methodMB.setString(Constants.GET); } else if (methodMB.equals(Constants.POST)) { methodMB.setString(Constants.POST); final MimeHeaders headers = request.getMimeHeaders(); request.scheme().setString(backendConfiguration.getScheme()); isSchemeSet = true; } else if (backendConfiguration.getSchemeMapping() != null) { String value = headers.getHeader(backendConfiguration.getSchemeMapping()); if (value != null) { request.scheme().setString(value); isSchemeSet = true; final MessageBytes remoteUserMB = request.getRemoteUser(); if (remoteUserMB.isNull() && backendConfiguration.getRemoteUserMapping() != null) { request.scheme().setString("https"); ByteChunk uriBC = request.requestURI().getByteChunk(); if (uriBC.startsWithIgnoreCase("http", 0)) { request.requestURI().setBytes(uriB, uriBCStart + pos + 1, 1); } else { request.requestURI().setBytes(uriB, uriBCStart + slashPos, uriBC.getLength() - slashPos);
contentDelimitation = false; if (sslSupport != null) { request.scheme().setString("https"); MessageBytes protocolMB = request.protocol(); if (protocolMB.equals(Constants.HTTP_11)) { http11 = true; protocolMB.setString(Constants.HTTP_11); } else if (protocolMB.equals(Constants.HTTP_10)) { http11 = false; MessageBytes methodMB = request.method(); if (methodMB.equals(Constants.GET)) { methodMB.setString(Constants.GET); MimeHeaders headers = request.getMimeHeaders(); request.getMimeHeaders().getValue("user-agent"); if (userAgentValueMB != null) { ByteChunk uriBC = request.requestURI().getByteChunk(); if (uriBC.startsWithIgnoreCase("http", 0)) { request.requestURI().setBytes (uriB, uriBCStart + pos + 1, 1); } else { request.requestURI().setBytes (uriB, uriBCStart + slashPos, uriBC.getLength() - slashPos);
MessageBytes expectMB = request.getMimeHeaders().getValue("expect"); if (expectMB != null && expectMB.indexOfIgnoreCase("100-continue", 0) != -1) { try { outputBuffer.sendAck(); Object sslO = sslSupport.getCipherSuite(); if (sslO != null) request.setAttribute (SSLSupport.CIPHER_SUITE_KEY, sslO); sslO = sslSupport.getPeerCertificateChain(false); if (sslO != null) request.setAttribute (SSLSupport.CERTIFICATE_KEY, sslO); sslO = sslSupport.getKeySize(); if (sslO != null) request.setAttribute (SSLSupport.KEY_SIZE_KEY, sslO); sslO = sslSupport.getSessionId(); if (sslO != null) request.setAttribute (SSLSupport.SESSION_ID_KEY, sslO); request.remoteAddr().setString(remoteAddr); request.localName().setString(localName); remoteHost = remoteAddr; } else { // all we can do is punt
MappingData mappingData = (MappingData) req.getNote(MAPPING_DATA); if (handlerCode == Interceptor.RESPONSE_PROCEEDED && mappingData != null) { boolean isWebContainer = mappingData.wrapper != null && String docroot = System.getProperty("com.sun.aas.instanceRoot") + File.separatorChar + "applications"; String uri = req.requestURI().toString(); fileCache.add(FileCache.DEFAULT_SERVLET_NAME, docroot, uri, req.serverName().toString(), req.getResponse().getMimeHeaders(), false); } else { req.action(ActionCode.ACTION_REQ_LOCALPORT_ATTRIBUTE, req); String docroot = SelectorThread.getSelector(req.getLocalAddress(), req.getLocalPort()).getWebAppRootPath(); String uri = req.requestURI().toString(); fileCache.add(FileCache.DEFAULT_SERVLET_NAME, docroot, uri, req.serverName().toString(), req.getResponse().getMimeHeaders(), false);
req.getURLDecoder().setAllowEncodedSlash(allowEncodedSlash); if (isHandleStaticResources()) { super.service(req, res); GrizzlyRequest request = (GrizzlyRequest) req.getNote(ADAPTER_NOTES); GrizzlyResponse response = (GrizzlyResponse) res.getNote(ADAPTER_NOTES); req.setNote(ADAPTER_NOTES, request); res.setNote(ADAPTER_NOTES, response); if (decodeURL){ MessageBytes decodedURI = req.decodedURI(); decodedURI.duplicate(req.requestURI()); try { HttpRequestURIDecoder.decode(decodedURI, req.getURLDecoder()); } catch (IOException ioe) { res.setStatus(400);
public HandShake(Request request) { setSecure(request.scheme().equals("https")); MimeHeaders mimeHeaders = request.getMimeHeaders(); checkForHeader(mimeHeaders, "Upgrade", "WebSocket"); checkForHeader(mimeHeaders, "Connection", "Upgrade"); resourcePath = request.requestURI().toString(); final MessageBytes messageBytes = request.queryString(); String queryString; if(messageBytes != null) { queryString = messageBytes.toString().trim(); if(!"".equals(queryString)) { resourcePath += "?" + request.queryString();
req.setNote(INVOKED_ADAPTER, null); req.setNote(INVOKED_ADAPTER, adapter); return; MappingData mappingData = null; try { MessageBytes decodedURI = req.decodedURI(); decodedURI.duplicate(req.requestURI()); mappingData = (MappingData) req.getNote(MAPPING_DATA); if (mappingData == null) { mappingData = new MappingData(); req.setNote(MAPPING_DATA, mappingData); } else { mappingData.recycle(); mappingData = (MappingData) req.getNote(MAPPING_DATA); mapUriWithSemicolon(req.serverName(), decodedURI, 0, mappingData); req.setNote(INVOKED_ADAPTER, adapter); } else { response.getResponse().setStatus(404); response.setStatus(404); if (logger.isLoggable(Level.FINE)) { logger.log(Level.FINE, "Invalid URL: " + req.decodedURI(), t);
/** * Intercept the request and decide if we cache the static resource. If the * static resource is already cached, return it. */ public int handle(Request req, int handlerCode) throws IOException{ if (fileCache == null) { return Interceptor.CONTINUE; } if (handlerCode == Interceptor.RESPONSE_PROCEEDED && fileCache.isEnabled()){ String docroot = SelectorThread.getSelector( socketChannel.socket().getLocalAddress(), socketChannel.socket().getLocalPort()).getWebAppRootPath(); String uri = req.requestURI().toString(); fileCache.add(FileCache.DEFAULT_SERVLET_NAME,docroot, uri, req.serverName().toString(), req.getResponse().getMimeHeaders(), false); } else if (handlerCode == Interceptor.REQUEST_LINE_PARSED) { if (fileCache.sendCache(req)){ return Interceptor.BREAK; } } return Interceptor.CONTINUE; }
/** * Intercept the request and decide if we cache the static resource. If the * static resource is already cached, return it. */ public int handle(Request req, int handlerCode) throws IOException{ if (fileCache == null) return Interceptor.CONTINUE; if (handlerCode == Interceptor.RESPONSE_PROCEEDED && fileCache.isEnabled()){ String docroot = SelectorThread.getWebAppRootPath(); MessageBytes mb = req.requestURI(); String uri = req.requestURI().toString(); fileCache.add(FileCache.DEFAULT_SERVLET_NAME,docroot,uri, req.getResponse().getMimeHeaders(),false); } else if (handlerCode == Interceptor.REQUEST_LINE_PARSED) { ByteChunk requestURI = req.requestURI().getByteChunk(); if (fileCache.sendCache(requestURI.getBytes(), requestURI.getStart(), requestURI.getLength(), socketChannel, keepAlive(req))){ return Interceptor.BREAK; } } return Interceptor.CONTINUE; }
req.action( ActionCode.ACTION_REQ_LOCAL_ADDR_ATTRIBUTE , null); res.setStatus(302); res.setMessage("Moved Temporarily"); res.setHeader("Location", req.scheme() + "://" + req.serverName() + ":" + req.getServerPort() + "/index.html"); res.setHeader("Connection", "close");
/** * Return <tt>true</tt> if the file is cached. */ protected final FileCacheEntry map(Request request){ FileCacheEntry entry = null; if ( !fileCache.isEmpty() ){ String uri = request.requestURI().toString(); entry = fileCache.get(uri); if (entry != null) { String host = request.serverName().toString(); if (!host.equals(entry.host)) { entry = null; } } recalcCacheStatsIfMonitoring(entry); } else { recalcCacheStatsIfMonitoring(null); } return entry; }
public void service(Request req, final Response res) throws Exception { MessageBytes mb = req.requestURI(); ByteChunk requestURI = mb.getByteChunk(); String uri = req.requestURI().toString(); if (uri.indexOf("..") >= 0) { res.setStatus(404); return; } service(uri, req, res); }
/** * Set the name of the server (virtual host) to process this request. * * @param name The server name */ public void setServerName(String name) { request.serverName().setString(name); }
/** * Return the names of all headers received with this request. */ public Enumeration getHeaderNames() { return request.getMimeHeaders().names(); }
@Override public String getRequestURI() { return request.requestURI().getString(); }