/** * Set compressable mime-type list * List contains users agents separated by ',' : * * ie: "text/html,text/xml,text/plain" */ public void setCompressableMimeTypes(String compressableMimeTypes) { if (compressableMimeTypes != null) { this.compressableMimeTypes = null; StringTokenizer st = new StringTokenizer(compressableMimeTypes, ","); while (st.hasMoreTokens()) { addCompressableMimeType(st.nextToken().trim()); } } }
/** * Add a mime-type which will be compressible * The mime-type String will be exactly matched * in the response mime-type header . * * @param mimeType mime-type string */ public void addCompressableMimeType(String mimeType) { compressableMimeTypes = addStringArray(compressableMimeTypes, mimeType); }
@Override public final void recycle(boolean isSocketClosing) { if (getInputBuffer() != null) { getInputBuffer().recycle(); } if (getOutputBuffer() != null) { getOutputBuffer().recycle(); } if (asyncStateMachine != null) { asyncStateMachine.recycle(); } httpUpgradeHandler = null; comet = false; recycleInternal(); }
setSocketWrapper(socketWrapper); getInputBuffer().init(socketWrapper, endpoint); getOutputBuffer().init(socketWrapper, endpoint); if (disableKeepAlive()) { socketWrapper.setKeepAliveLeft(0); while (!error && keepAlive && !comet && !isAsync() && !endpoint.isPaused()) { setRequestLineReadTimeout(); if (!getInputBuffer().parseRequestLine(keptAlive)) { if (handleIncompleteRequestLineRead()) { break; if (!getInputBuffer().parseHeaders()) { setSocketTimeout(connectionUploadTimeout); if (getLog().isDebugEnabled()) { getLog().debug( sm.getString("http11processor.header.parse"), e); } catch (Throwable t) { ExceptionUtils.handleThrowable(t); if (getLog().isDebugEnabled()) { getLog().debug( sm.getString("http11processor.header.parse"), t);
OutputFilter[] outputFilters = getOutputBuffer().getFilters(); getOutputBuffer().addActiveFilter (outputFilters[Constants.IDENTITY_FILTER]); return; getOutputBuffer().addActiveFilter (outputFilters[Constants.VOID_FILTER]); entityBody = false; getOutputBuffer().addActiveFilter (outputFilters[Constants.VOID_FILTER]); contentDelimitation = true; if (getEndpoint().getUseSendfile()) { sendingWithSendfile = prepareSendfile(outputFilters); boolean useCompression = false; if (entityBody && (compressionLevel > 0) && !sendingWithSendfile) { isCompressable = isCompressable(); if (isCompressable) { useCompression = useCompression(); if (contentLength != -1) { headers.setValue("Content-Length").setLong(contentLength); getOutputBuffer().addActiveFilter (outputFilters[Constants.IDENTITY_FILTER]); contentDelimitation = true; } else {
prepareRequestInternal(); if (getLog().isDebugEnabled()) { getLog().debug(sm.getString("http11processor.request.prepare")+ " Unsupported HTTP version \""+protocolMB+"\""); if (connectionValueMB != null) { ByteChunk connectionValueBC = connectionValueMB.getByteChunk(); if (findBytes(connectionValueBC, Constants.CLOSE_BYTES) != -1) { keepAlive = false; } else if (findBytes(connectionValueBC, Constants.KEEPALIVE_BYTES) != -1) { keepAlive = true; getInputBuffer().setSwallowInput(false); expectation = true; InputFilter[] inputFilters = getInputBuffer().getFilters(); encodingName = transferEncodingValue.substring (startPos, commaPos).toLowerCase(Locale.ENGLISH).trim(); if (!addInputFilter(inputFilters, encodingName)) { if (!addInputFilter(inputFilters, encodingName)) { if (getLog().isDebugEnabled()) { getLog().debug(sm.getString("http11processor.request.prepare")+ " Unsupported transfer encoding \""+encodingName+"\"");
getOutputBuffer().endRequest(); } catch (IOException e) { prepareResponse(); getOutputBuffer().commit(); } catch (IOException e) { getInputBuffer().setSwallowInput(true); try { getOutputBuffer().sendAck(); } catch (IOException e) { getOutputBuffer().flush(); } catch (IOException e) { getInputBuffer().setSwallowInput(false); getOutputBuffer().reset(); getOutputBuffer().finished = true; } else if (actionCode == ActionCode.AVAILABLE) { request.setAvailable(inputBuffer.available()); AtomicBoolean isReady = (AtomicBoolean)param; try { isReady.set(getOutputBuffer().isReady()); } catch (IOException e) { getLog().debug("isReady() failed", e); error = true;
getOutputBuffer().endRequest(); } catch (IOException e) { prepareResponse(); getOutputBuffer().commit(); } catch (IOException e) { getInputBuffer().setSwallowInput(true); try { getOutputBuffer().sendAck(); } catch (IOException e) { getOutputBuffer().flush(); } catch (IOException e) { getInputBuffer().setSwallowInput(false); getOutputBuffer().reset(); ((AtomicBoolean) param).set(asyncStateMachine.isAsyncTimingOut()); } else { actionInternal(actionCode, param);
rp.setStage(org.apache.coyote.Constants.STAGE_SERVICE); error = !adapter.asyncDispatch(request, response, status); resetTimeouts(); } catch (InterruptedIOException e) { error = true; } catch (Throwable t) { ExceptionUtils.handleThrowable(t); getLog().error(sm.getString("http11processor.request.process"), t); error = true; } finally { } else if (isAsync()) { return SocketState.LONG; } else { return SocketState.CLOSED; } else { getInputBuffer().nextRequest(); getOutputBuffer().nextRequest(); return SocketState.OPEN;
public void endRequest() { // Finish the handling of the request try { getInputBuffer().endRequest(); } catch (IOException e) { error = true; } catch (Throwable t) { ExceptionUtils.handleThrowable(t); getLog().error(sm.getString("http11processor.request.finish"), t); // 500 - Internal Server Error // Can't add a 500 to the access log since that has already been // written in the Adapter.service method. response.setStatus(500); error = true; } try { getOutputBuffer().endRequest(); } catch (IOException e) { error = true; } catch (Throwable t) { ExceptionUtils.handleThrowable(t); getLog().error(sm.getString("http11processor.response.finish"), t); error = true; } }
if (getLog().isDebugEnabled()) { getLog().debug("Unable to write async data.",x); registerForEvent(false, true); registerForEvent(true, false); try { rp.setStage(org.apache.coyote.Constants.STAGE_SERVICE); error = !getAdapter().asyncDispatch(request, response, status); resetTimeouts(); } catch (InterruptedIOException e) { error = true; } catch (Throwable t) { ExceptionUtils.handleThrowable(t); getLog().error(sm.getString("http11processor.request.process"), t); error = true; } else if (isAsync()) { return SocketState.LONG; } else { return SocketState.CLOSED; } else { getInputBuffer().nextRequest(); getOutputBuffer().nextRequest(); return SocketState.OPEN;
/** * Initialize standard input and output filters. */ protected void initializeFilters(int maxTrailerSize) { // Create and add the identity filters. getInputBuffer().addFilter(new IdentityInputFilter()); getOutputBuffer().addFilter(new IdentityOutputFilter()); // Create and add the chunked filters. getInputBuffer().addFilter(new ChunkedInputFilter(maxTrailerSize)); getOutputBuffer().addFilter(new ChunkedOutputFilter()); // Create and add the void filters. getInputBuffer().addFilter(new VoidInputFilter()); getOutputBuffer().addFilter(new VoidOutputFilter()); // Create and add buffered input filter getInputBuffer().addFilter(new BufferedInputFilter()); // Create and add the chunked filters. //getInputBuffer().addFilter(new GzipInputFilter()); getOutputBuffer().addFilter(new GzipOutputFilter()); pluggableFilterIndex = getInputBuffer().getFilters().length; }
/** * Add an input filter to the current request. * * @return false if the encoding was not found (which would mean it is * unsupported) */ protected boolean addInputFilter(InputFilter[] inputFilters, String encodingName) { if (encodingName.equals("identity")) { // Skip } else if (encodingName.equals("chunked")) { getInputBuffer().addActiveFilter (inputFilters[Constants.CHUNKED_FILTER]); contentDelimitation = true; } else { for (int i = pluggableFilterIndex; i < inputFilters.length; i++) { if (inputFilters[i].getEncodingName() .toString().equals(encodingName)) { getInputBuffer().addActiveFilter(inputFilters[i]); return true; } } return false; } return true; }
public AbstractHttp11Processor(AbstractEndpoint<S> endpoint) { super(endpoint); userDataHelper = new UserDataHelper(getLog()); }
setSocketWrapper(socketWrapper); getInputBuffer().init(socketWrapper, endpoint); getOutputBuffer().init(socketWrapper, endpoint); if (disableKeepAlive()) { socketWrapper.setKeepAliveLeft(0); while (!error && keepAlive && !comet && !isAsync() && httpUpgradeHandler == null && !endpoint.isPaused()) { setRequestLineReadTimeout(); if (!getInputBuffer().parseRequestLine(keptAlive)) { if (handleIncompleteRequestLineRead()) { break; if (!getInputBuffer().parseHeaders()) { setSocketTimeout(connectionUploadTimeout); if (getLog().isDebugEnabled()) { getLog().debug( sm.getString("http11processor.header.parse"), e); getLog().info(message); break; case DEBUG: getLog().debug(message);
OutputFilter[] outputFilters = getOutputBuffer().getFilters(); getOutputBuffer().addActiveFilter (outputFilters[Constants.IDENTITY_FILTER]); return; getOutputBuffer().addActiveFilter (outputFilters[Constants.VOID_FILTER]); entityBody = false; getOutputBuffer().addActiveFilter (outputFilters[Constants.VOID_FILTER]); contentDelimitation = true; if (getEndpoint().getUseSendfile()) { sendingWithSendfile = prepareSendfile(outputFilters); boolean useCompression = false; if (entityBody && (compressionLevel > 0) && !sendingWithSendfile) { isCompressable = isCompressable(); if (isCompressable) { useCompression = useCompression(); if (contentLength != -1) { headers.setValue("Content-Length").setLong(contentLength); getOutputBuffer().addActiveFilter (outputFilters[Constants.IDENTITY_FILTER]); contentDelimitation = true; } else {
prepareRequestInternal(); if (getLog().isDebugEnabled()) { getLog().debug(sm.getString("http11processor.request.prepare")+ " Unsupported HTTP version \""+protocolMB+"\""); if (connectionValueMB != null) { ByteChunk connectionValueBC = connectionValueMB.getByteChunk(); if (findBytes(connectionValueBC, Constants.CLOSE_BYTES) != -1) { keepAlive = false; } else if (findBytes(connectionValueBC, Constants.KEEPALIVE_BYTES) != -1) { keepAlive = true; getInputBuffer().setSwallowInput(false); expectation = true; InputFilter[] inputFilters = getInputBuffer().getFilters(); encodingName = transferEncodingValue.substring (startPos, commaPos).toLowerCase(Locale.ENGLISH).trim(); if (!addInputFilter(inputFilters, encodingName)) { if (!addInputFilter(inputFilters, encodingName)) { if (getLog().isDebugEnabled()) { getLog().debug(sm.getString("http11processor.request.prepare")+ " Unsupported transfer encoding \""+encodingName+"\"");
getOutputBuffer().endRequest(); } catch (IOException e) { prepareResponse(); getOutputBuffer().commit(); } catch (IOException e) { getInputBuffer().setSwallowInput(true); try { getOutputBuffer().sendAck(); } catch (IOException e) { getOutputBuffer().flush(); } catch (IOException e) { getInputBuffer().setSwallowInput(false); getOutputBuffer().reset(); upgradeInbound = (UpgradeInbound) param; getOutputBuffer().finished = true; } else { actionInternal(actionCode, param);
rp.setStage(org.apache.coyote.Constants.STAGE_SERVICE); error = !adapter.asyncDispatch(request, response, status); resetTimeouts(); } catch (InterruptedIOException e) { error = true; } catch (Throwable t) { ExceptionUtils.handleThrowable(t); getLog().error(sm.getString("http11processor.request.process"), t); error = true; } finally { } else if (isAsync()) { return SocketState.LONG; } else { return SocketState.CLOSED; } else { getInputBuffer().nextRequest(); getOutputBuffer().nextRequest(); return SocketState.OPEN;
public void endRequest() { // Finish the handling of the request try { getInputBuffer().endRequest(); } catch (IOException e) { error = true; } catch (Throwable t) { ExceptionUtils.handleThrowable(t); getLog().error(sm.getString("http11processor.request.finish"), t); // 500 - Internal Server Error // Can't add a 500 to the access log since that has already been // written in the Adapter.service method. response.setStatus(500); error = true; } try { getOutputBuffer().endRequest(); } catch (IOException e) { error = true; } catch (Throwable t) { ExceptionUtils.handleThrowable(t); getLog().error(sm.getString("http11processor.response.finish"), t); error = true; } }