org.apache.coyote.ActionCode Java Examples
The following examples show how to use
org.apache.coyote.ActionCode.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractOutputBuffer.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
/** * Write the contents of a byte chunk. * * @param chunk byte chunk * @return number of bytes written * @throws IOException an underlying I/O error occurred */ @Override public int doWrite(ByteChunk chunk, Response res) throws IOException { if (!committed) { // Send the connector a request for commit. The connector should // then validate the headers, send them (using sendHeaders) and // set the filters accordingly. response.action(ActionCode.COMMIT, null); } if (lastActiveFilter == -1) return outputStreamOutputBuffer.doWrite(chunk, res); else return activeFilters[lastActiveFilter].doWrite(chunk, res); }
Example #2
Source File: AbstractOutputBuffer.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * Flush the response. * * @throws IOException an underlying I/O error occurred */ public void flush() throws IOException { if (!committed) { // Send the connector a request for commit. The connector should // then validate the headers, send them (using sendHeader) and // set the filters accordingly. response.action(ActionCode.COMMIT, null); } // go through the filters and if there is gzip filter // invoke it to flush for (int i = 0; i <= lastActiveFilter; i++) { if (activeFilters[i] instanceof GzipOutputFilter) { if (log.isDebugEnabled()) { log.debug("Flushing the gzip filter at position " + i + " of the filter chain..."); } ((GzipOutputFilter) activeFilters[i]).flush(); break; } } }
Example #3
Source File: InternalNioOutputBuffer.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * Write chunk. */ @Override public int doWrite(ByteChunk chunk, Response res) throws IOException { try { int len = chunk.getLength(); int start = chunk.getStart(); byte[] b = chunk.getBuffer(); addToBB(b, start, len); byteCount += chunk.getLength(); return chunk.getLength(); } catch (IOException ioe) { response.action(ActionCode.CLOSE_NOW, ioe); // Re-throw throw ioe; } }
Example #4
Source File: AuthenticatorBase.java From Tomcat8-Source-Read with MIT License | 6 votes |
/** * Look for the X509 certificate chain in the Request under the key * <code>javax.servlet.request.X509Certificate</code>. If not found, trigger * extracting the certificate chain from the Coyote request. * * @param request * Request to be processed * * @return The X509 certificate chain if found, <code>null</code> otherwise. */ protected X509Certificate[] getRequestCertificates(final Request request) throws IllegalStateException { X509Certificate certs[] = (X509Certificate[]) request.getAttribute(Globals.CERTIFICATES_ATTR); if ((certs == null) || (certs.length < 1)) { try { request.getCoyoteRequest().action(ActionCode.REQ_SSL_CERTIFICATE, null); certs = (X509Certificate[]) request.getAttribute(Globals.CERTIFICATES_ATTR); } catch (IllegalStateException ise) { // Request body was too large for save buffer // Return null which will trigger an auth failure } } return certs; }
Example #5
Source File: AbstractOutputBuffer.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * End request. * * @throws IOException an underlying I/O error occurred */ public void endRequest() throws IOException { if (!committed) { // Send the connector a request for commit. The connector should // then validate the headers, send them (using sendHeader) and // set the filters accordingly. response.action(ActionCode.COMMIT, null); } if (finished) return; if (lastActiveFilter != -1) activeFilters[lastActiveFilter].end(); finished = true; }
Example #6
Source File: AuthenticatorBase.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
/** * Look for the X509 certificate chain in the Request under the key * <code>javax.servlet.request.X509Certificate</code>. If not found, trigger * extracting the certificate chain from the Coyote request. * * @param request Request to be processed * * @return The X509 certificate chain if found, <code>null</code> * otherwise. */ protected X509Certificate[] getRequestCertificates(final Request request) throws IllegalStateException { X509Certificate certs[] = (X509Certificate[]) request.getAttribute(Globals.CERTIFICATES_ATTR); if ((certs == null) || (certs.length < 1)) { try { request.getCoyoteRequest().action(ActionCode.REQ_SSL_CERTIFICATE, null); certs = (X509Certificate[]) request.getAttribute(Globals.CERTIFICATES_ATTR); } catch (IllegalStateException ise) { // Request body was too large for save buffer // Return null which will trigger an auth failure } } return certs; }
Example #7
Source File: AuthenticatorBase.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * Look for the X509 certificate chain in the Request under the key * <code>javax.servlet.request.X509Certificate</code>. If not found, trigger * extracting the certificate chain from the Coyote request. * * @param request Request to be processed * * @return The X509 certificate chain if found, <code>null</code> * otherwise. */ protected X509Certificate[] getRequestCertificates(final Request request) throws IllegalStateException { X509Certificate certs[] = (X509Certificate[]) request.getAttribute(Globals.CERTIFICATES_ATTR); if ((certs == null) || (certs.length < 1)) { try { request.getCoyoteRequest().action(ActionCode.REQ_SSL_CERTIFICATE, null); certs = (X509Certificate[]) request.getAttribute(Globals.CERTIFICATES_ATTR); } catch (IllegalStateException ise) { // Request body was too large for save buffer // Return null which will trigger an auth failure } } return certs; }
Example #8
Source File: AbstractOutputBuffer.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
/** * End request. * * @throws IOException an underlying I/O error occurred */ public void endRequest() throws IOException { if (!committed) { // Send the connector a request for commit. The connector should // then validate the headers, send them (using sendHeader) and // set the filters accordingly. response.action(ActionCode.COMMIT, null); } if (finished) return; if (lastActiveFilter != -1) activeFilters[lastActiveFilter].end(); finished = true; }
Example #9
Source File: InputBuffer.java From Tomcat8-Source-Read with MIT License | 6 votes |
public void setReadListener(ReadListener listener) { coyoteRequest.setReadListener(listener); // The container is responsible for the first call to // listener.onDataAvailable(). If isReady() returns true, the container // needs to call listener.onDataAvailable() from a new thread. If // isReady() returns false, the socket will be registered for read and // the container will call listener.onDataAvailable() once data arrives. // Must call isFinished() first as a call to isReady() if the request // has been finished will register the socket for read interest and that // is not required. if (!coyoteRequest.isFinished() && isReady()) { coyoteRequest.action(ActionCode.DISPATCH_READ, null); if (!ContainerThreadMarker.isContainerThread()) { // Not on a container thread so need to execute the dispatch coyoteRequest.action(ActionCode.DISPATCH_EXECUTE, null); } } }
Example #10
Source File: InternalOutputBuffer.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * Write chunk. */ @Override public int doWrite(ByteChunk chunk, Response res) throws IOException { try { int length = chunk.getLength(); if (useSocketBuffer) { socketBuffer.append(chunk.getBuffer(), chunk.getStart(), length); } else { outputStream.write(chunk.getBuffer(), chunk.getStart(), length); } byteCount += chunk.getLength(); return chunk.getLength(); } catch (IOException ioe) { response.action(ActionCode.CLOSE_NOW, ioe); // Re-throw throw ioe; } }
Example #11
Source File: Stream.java From Tomcat8-Source-Read with MIT License | 6 votes |
synchronized boolean onDataAvailable() { if (readInterest) { if (log.isDebugEnabled()) { log.debug(sm.getString("stream.inputBuffer.dispatch")); } readInterest = false; coyoteRequest.action(ActionCode.DISPATCH_READ, null); // Always need to dispatch since this thread is processing // the incoming connection and streams are processed on their // own. coyoteRequest.action(ActionCode.DISPATCH_EXECUTE, null); return true; } else { if (log.isDebugEnabled()) { log.debug(sm.getString("stream.inputBuffer.signal")); } synchronized (inBuffer) { inBuffer.notifyAll(); } return false; } }
Example #12
Source File: Http11OutputBuffer.java From Tomcat8-Source-Read with MIT License | 6 votes |
/** * @deprecated Unused. Will be removed in Tomcat 9. Use * {@link #doWrite(ByteBuffer)} */ @Deprecated @Override public int doWrite(ByteChunk chunk) throws IOException { if (!response.isCommitted()) { // Send the connector a request for commit. The connector should // then validate the headers, send them (using sendHeaders) and // set the filters accordingly. response.action(ActionCode.COMMIT, null); } if (lastActiveFilter == -1) { return outputStreamOutputBuffer.doWrite(chunk); } else { return activeFilters[lastActiveFilter].doWrite(chunk); } }
Example #13
Source File: Request.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
/** * Disable swallowing of remaining input if configured */ protected void checkSwallowInput() { Context context = getContext(); if (context != null && !context.getSwallowAbortedUploads()) { coyoteRequest.action(ActionCode.DISABLE_SWALLOW_INPUT, null); } }
Example #14
Source File: Request.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
/** * @deprecated Will be removed in Tomcat 8.0.x. */ @Deprecated public void doUpgrade(org.apache.coyote.http11.upgrade.UpgradeInbound inbound) throws IOException { coyoteRequest.action(ActionCode.UPGRADE_TOMCAT, inbound); // Output required by RFC2616. Protocol specific headers should have // already been set. response.setStatus(HttpServletResponse.SC_SWITCHING_PROTOCOLS); response.flushBuffer(); }
Example #15
Source File: AsyncContextImpl.java From tomcatsrc with Apache License 2.0 | 5 votes |
public void setStarted(Context context, ServletRequest request, ServletResponse response, boolean originalRequestResponse) { synchronized (asyncContextLock) { this.request.getCoyoteRequest().action( ActionCode.ASYNC_START, this); this.context = context; this.servletRequest = request; this.servletResponse = response; this.hasOriginalRequestAndResponse = originalRequestResponse; this.event = new AsyncEvent(this, request, response); List<AsyncListenerWrapper> listenersCopy = new ArrayList<AsyncListenerWrapper>(); listenersCopy.addAll(listeners); listeners.clear(); for (AsyncListenerWrapper listener : listenersCopy) { try { listener.fireOnStartAsync(event); } catch (Throwable t) { ExceptionUtils.handleThrowable(t); log.warn("onStartAsync() failed for listener of type [" + listener.getClass().getName() + "]", t); } } } }
Example #16
Source File: AsyncContextImpl.java From tomcatsrc with Apache License 2.0 | 5 votes |
@Override public void complete() { if (log.isDebugEnabled()) { logDebug("complete "); } check(); request.getCoyoteRequest().action(ActionCode.ASYNC_COMPLETE, null); }
Example #17
Source File: OutputBuffer.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
/** * Flush bytes or chars contained in the buffer. * * @throws IOException An underlying IOException occurred */ protected void doFlush(boolean realFlush) throws IOException { if (suspended) { return; } try { doFlush = true; if (initial) { coyoteResponse.sendHeaders(); initial = false; } if (cb.getLength() > 0) { cb.flushBuffer(); } if (bb.getLength() > 0) { bb.flushBuffer(); } } finally { doFlush = false; } if (realFlush) { coyoteResponse.action(ActionCode.CLIENT_FLUSH, null); // If some exception occurred earlier, or if some IOE occurred // here, notify the servlet with an IOE if (coyoteResponse.isExceptionPresent()) { throw new ClientAbortException(coyoteResponse.getErrorException()); } } }
Example #18
Source File: Request.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
/** * Returns the Internet Protocol (IP) address of the interface on * which the request was received. */ @Override public String getLocalAddr(){ if (localAddr == null) { coyoteRequest.action (ActionCode.REQ_LOCAL_ADDR_ATTRIBUTE, coyoteRequest); localAddr = coyoteRequest.localAddr().toString(); } return localAddr; }
Example #19
Source File: AsyncContextImpl.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
public boolean timeout() { AtomicBoolean result = new AtomicBoolean(); request.getCoyoteRequest().action(ActionCode.ASYNC_TIMEOUT, result); if (result.get()) { ClassLoader oldCL = Thread.currentThread().getContextClassLoader(); ClassLoader newCL = request.getContext().getLoader().getClassLoader(); try { Thread.currentThread().setContextClassLoader(newCL); List<AsyncListenerWrapper> listenersCopy = new ArrayList<AsyncListenerWrapper>(); listenersCopy.addAll(listeners); for (AsyncListenerWrapper listener : listenersCopy) { try { listener.fireOnTimeout(event); } catch (Throwable t) { ExceptionUtils.handleThrowable(t); log.warn("onTimeout() failed for listener of type [" + listener.getClass().getName() + "]", t); } } request.getCoyoteRequest().action( ActionCode.ASYNC_IS_TIMINGOUT, result); return !result.get(); } finally { Thread.currentThread().setContextClassLoader(oldCL); } } return true; }
Example #20
Source File: Request.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
/** * Returns the host name of the Internet Protocol (IP) interface on * which the request was received. */ @Override public String getLocalName(){ if (localName == null) { coyoteRequest.action (ActionCode.REQ_LOCAL_NAME_ATTRIBUTE, coyoteRequest); localName = coyoteRequest.localName().toString(); } return localName; }
Example #21
Source File: Request.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
/** * Returns the Internet Protocol (IP) source port of the client * or last proxy that sent the request. */ @Override public int getRemotePort(){ if (remotePort == -1) { coyoteRequest.action (ActionCode.REQ_REMOTEPORT_ATTRIBUTE, coyoteRequest); remotePort = coyoteRequest.getRemotePort(); } return remotePort; }
Example #22
Source File: Request.java From tomcatsrc with Apache License 2.0 | 5 votes |
public boolean isAsync() { if (asyncContext == null) { return false; } AtomicBoolean result = new AtomicBoolean(false); coyoteRequest.action(ActionCode.ASYNC_IS_ASYNC, result); return result.get(); }
Example #23
Source File: Request.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
/** * Return the remote IP address making this Request. */ @Override public String getRemoteAddr() { if (remoteAddr == null) { coyoteRequest.action (ActionCode.REQ_HOST_ADDR_ATTRIBUTE, coyoteRequest); remoteAddr = coyoteRequest.remoteAddr().toString(); } return remoteAddr; }
Example #24
Source File: AjpAprProcessor.java From tomcatsrc with Apache License 2.0 | 5 votes |
/** * Send an action to the connector. * * @param actionCode Type of the action * @param param Action parameter */ @Override @SuppressWarnings("incomplete-switch") // Other cases are handled by action() protected void actionInternal(ActionCode actionCode, Object param) { switch (actionCode) { case ASYNC_COMPLETE: { if (asyncStateMachine.asyncComplete()) { ((AprEndpoint)endpoint).processSocketAsync(this.socketWrapper, SocketStatus.OPEN_READ); } break; } case ASYNC_SETTIMEOUT: { if (param == null) return; long timeout = ((Long)param).longValue(); socketWrapper.setTimeout(timeout); break; } case ASYNC_DISPATCH: { if (asyncStateMachine.asyncDispatch()) { ((AprEndpoint)endpoint).processSocketAsync(this.socketWrapper, SocketStatus.OPEN_READ); } break; } } }
Example #25
Source File: AsyncContextImpl.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
public void setStarted(Context context, ServletRequest request, ServletResponse response, boolean originalRequestResponse) { synchronized (asyncContextLock) { this.request.getCoyoteRequest().action( ActionCode.ASYNC_START, this); this.context = context; this.servletRequest = request; this.servletResponse = response; this.hasOriginalRequestAndResponse = originalRequestResponse; this.event = new AsyncEvent(this, request, response); List<AsyncListenerWrapper> listenersCopy = new ArrayList<AsyncListenerWrapper>(); listenersCopy.addAll(listeners); listeners.clear(); for (AsyncListenerWrapper listener : listenersCopy) { try { listener.fireOnStartAsync(event); } catch (Throwable t) { ExceptionUtils.handleThrowable(t); log.warn("onStartAsync() failed for listener of type [" + listener.getClass().getName() + "]", t); } } } }
Example #26
Source File: AsyncContextImpl.java From tomcatsrc with Apache License 2.0 | 5 votes |
public boolean timeout() { AtomicBoolean result = new AtomicBoolean(); request.getCoyoteRequest().action(ActionCode.ASYNC_TIMEOUT, result); if (result.get()) { ClassLoader oldCL = Thread.currentThread().getContextClassLoader(); ClassLoader newCL = request.getContext().getLoader().getClassLoader(); try { Thread.currentThread().setContextClassLoader(newCL); List<AsyncListenerWrapper> listenersCopy = new ArrayList<AsyncListenerWrapper>(); listenersCopy.addAll(listeners); for (AsyncListenerWrapper listener : listenersCopy) { try { listener.fireOnTimeout(event); } catch (Throwable t) { ExceptionUtils.handleThrowable(t); log.warn("onTimeout() failed for listener of type [" + listener.getClass().getName() + "]", t); } } request.getCoyoteRequest().action( ActionCode.ASYNC_IS_TIMINGOUT, result); return !result.get(); } finally { Thread.currentThread().setContextClassLoader(oldCL); } } return true; }
Example #27
Source File: InternalAprOutputBuffer.java From tomcatsrc with Apache License 2.0 | 5 votes |
/** * Write chunk. */ @Override public int doWrite(ByteChunk chunk, Response res) throws IOException { try { int len = chunk.getLength(); int start = chunk.getStart(); byte[] b = chunk.getBuffer(); while (len > 0) { int thisTime = len; if (bbuf.position() == bbuf.capacity()) { flushBuffer(); } if (thisTime > bbuf.capacity() - bbuf.position()) { thisTime = bbuf.capacity() - bbuf.position(); } bbuf.put(b, start, thisTime); len = len - thisTime; start = start + thisTime; } byteCount += chunk.getLength(); return chunk.getLength(); } catch (IOException ioe) { response.action(ActionCode.CLOSE_NOW, ioe); // Re-throw throw ioe; } }
Example #28
Source File: AjpNioProcessor.java From tomcatsrc with Apache License 2.0 | 5 votes |
/** * Send an action to the connector. * * @param actionCode Type of the action * @param param Action parameter */ @Override @SuppressWarnings("incomplete-switch") // Other cases are handled by action() protected void actionInternal(ActionCode actionCode, Object param) { switch (actionCode) { case ASYNC_COMPLETE: { if (asyncStateMachine.asyncComplete()) { ((NioEndpoint)endpoint).processSocket(this.socketWrapper.getSocket(), SocketStatus.OPEN_READ, false); } break; } case ASYNC_SETTIMEOUT: { if (param == null) return; long timeout = ((Long)param).longValue(); final KeyAttachment ka = (KeyAttachment)socketWrapper.getSocket().getAttachment(); ka.setTimeout(timeout); break; } case ASYNC_DISPATCH: { if (asyncStateMachine.asyncDispatch()) { ((NioEndpoint)endpoint).processSocket(this.socketWrapper.getSocket(), SocketStatus.OPEN_READ, true); } break; } } }
Example #29
Source File: AjpAprProcessor.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
/** * Send an action to the connector. * * @param actionCode Type of the action * @param param Action parameter */ @Override @SuppressWarnings("incomplete-switch") // Other cases are handled by action() protected void actionInternal(ActionCode actionCode, Object param) { switch (actionCode) { case ASYNC_COMPLETE: { if (asyncStateMachine.asyncComplete()) { ((AprEndpoint)endpoint).processSocketAsync(this.socketWrapper, SocketStatus.OPEN_READ); } break; } case ASYNC_SETTIMEOUT: { if (param == null) return; long timeout = ((Long)param).longValue(); socketWrapper.setTimeout(timeout); break; } case ASYNC_DISPATCH: { if (asyncStateMachine.asyncDispatch()) { ((AprEndpoint)endpoint).processSocketAsync(this.socketWrapper, SocketStatus.OPEN_READ); } break; } } }
Example #30
Source File: Request.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
/** * Returns the Internet Protocol (IP) port number of the interface * on which the request was received. */ @Override public int getLocalPort(){ if (localPort == -1){ coyoteRequest.action (ActionCode.REQ_LOCALPORT_ATTRIBUTE, coyoteRequest); localPort = coyoteRequest.getLocalPort(); } return localPort; }