/** * Finish AJP response. */ protected void finish() throws IOException { if (!response.isCommitted()) { // Validate and write response headers try { prepareResponse(); } catch (IOException e) { // Set error flag error = true; } } if (finished) return; finished = true; // Swallow the unread body packet if present if (first && request.getContentLengthLong() > 0 || waitingForBodyMessage) { receive(true); } // Add the end message if (error) { output(endAndCloseMessageArray, 0, endAndCloseMessageArray.length, true); } else { output(endMessageArray, 0, endMessageArray.length, true); } }
@Override public void recycle(boolean socketClosing) { super.recycle(socketClosing); if (socketClosing) { input = null; output = null; } }
/** * Get more request body data from the web server and store it in the * internal buffer. * * @return true if there is more data, false if not. */ protected boolean refillReadBuffer() throws IOException { // If the server returns an empty packet, assume that that end of // the stream has been reached (yuck -- fix protocol??). // FORM support if (replay) { endOfStream = true; // we've read everything there is } if (endOfStream) { return false; } // Request more data immediately output(getBodyMessageArray, 0, getBodyMessageArray.length); boolean moreData = receive(); if( !moreData ) { endOfStream = true; } return moreData; }
prepareResponse(); } catch (IOException e) { flush(false); } catch (IOException e) { prepareResponse(); } catch (IOException e) { flush(true); } catch (IOException e) { finish(); } catch (IOException e) { getLog().error(sm.getString("ajpprocessor.certs.fail"), e); return; } catch (NoSuchProviderException e) { getLog().error(sm.getString("ajpprocessor.certs.fail"), e); return; actionInternal(actionCode, param);
setupSocket(socket); if (!readMessage(requestHeaderMessage, !keptAlive)) { break; setTimeout(socketWrapper, soTimeout); if (type == Constants.JK_AJP13_CPING_REQUEST) { if (endpoint.isPaused()) { recycle(true); break; output(pongMessageArray, 0, pongMessageArray.length, true); } catch (IOException e) { error = true; recycle(false); continue; } else if(type != Constants.JK_AJP13_FORWARD_REQUEST) { if (getLog().isDebugEnabled()) { getLog().debug("Unexpected message: " + type); } catch (Throwable t) { ExceptionUtils.handleThrowable(t); getLog().debug(sm.getString("ajpprocessor.header.error"), t); getAdapter().log(request, response, 0); error = true;
finish(); } catch (IOException e) { prepareResponse(); } catch (IOException e) { flush(false); } catch (IOException e) { prepareResponse(); } catch (IOException e) { flush(true); } catch (IOException e) { getLog().error(sm.getString("ajpprocessor.certs.fail"), e); return; } catch (NoSuchProviderException e) { getLog().error(sm.getString("ajpprocessor.certs.fail"), e); return; if (available()) { request.setAvailable(1); } else { registerForEvent(true, false); isReady.set(result); if (!result) {
asyncStateMachine.asyncOperation(); try { if (hasDataToWrite()) { flushBufferedData(); if (hasDataToWrite()) { if (getLog().isDebugEnabled()) { getLog().debug("Unable to write async data.",x); registerForEvent(false, true); if (available()) { asyncStateMachine.asyncOperation(); 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; if (isAsync()) { if (error) {
/** * Callback to write data from the buffer. */ protected void flush(boolean explicit) throws IOException { if (explicit && !finished) { // Send the flush message output(flushMessageArray, 0, flushMessageArray.length); } }
/** * Read bytes into the specified chunk. */ @Override public int doRead(ByteChunk chunk, Request req ) throws IOException { if (endOfStream) { return -1; } if (first && req.getContentLengthLong() > 0) { // Handle special first-body-chunk if (!receive()) { return 0; } } else if (empty) { if (!refillReadBuffer()) { return -1; } } ByteChunk bc = bodyBytes.getByteChunk(); chunk.setBytes(bc.getBuffer(), bc.getStart(), bc.getLength()); empty = true; return chunk.getLength(); }
parseHost(valueMB); getAdapter().log(request, response, 0);
prepareResponse(); } catch (IOException e) { flush(false); } catch (IOException e) { prepareResponse(); } catch (IOException e) { flush(true); } catch (IOException e) { finish(); } catch (IOException e) { getLog().error(sm.getString("ajpprocessor.certs.fail"), e); return; } catch (NoSuchProviderException e) { getLog().error(sm.getString("ajpprocessor.certs.fail"), e); return; ((AtomicBoolean) param).set(asyncStateMachine.isAsyncTimingOut()); } else { actionInternal(actionCode, param);
/** * Get more request body data from the web server and store it in the * internal buffer. * * @return true if there is more data, false if not. */ protected boolean refillReadBuffer(boolean block) throws IOException { // If the server returns an empty packet, assume that that end of // the stream has been reached (yuck -- fix protocol??). // FORM support if (replay) { endOfStream = true; // we've read everything there is } if (endOfStream) { return false; } // Request more data immediately if (!first && !waitingForBodyMessage) { output(getBodyMessageArray, 0, getBodyMessageArray.length, true); waitingForBodyMessage = true; } boolean moreData = receive(block); if (!moreData && ((first && !bodyPresent) || (!first && !waitingForBodyMessage))) { endOfStream = true; } return moreData; }
/** * Callback to write data from the buffer. */ protected void flush(boolean explicit) throws IOException { // Calling code should ensure that there is no data in the buffers for // non-blocking writes. // TODO Validate the assertion above if (explicit && !finished) { // Send the flush message output(flushMessageArray, 0, flushMessageArray.length, true); } }
prepareResponse(); } catch (IOException e) { flush(false); } catch (IOException e) { prepareResponse(); } catch (IOException e) { flush(true); } catch (IOException e) { finish(); } catch (IOException e) { getLog().error(sm.getString("ajpprocessor.certs.fail"), e); return; ((AtomicBoolean) param).set(asyncStateMachine.isAsyncTimingOut()); } else { actionInternal(actionCode, param);
/** * Finish AJP response. */ protected void finish() throws IOException { if (!response.isCommitted()) { // Validate and write response headers try { prepareResponse(); } catch (IOException e) { // Set error flag error = true; } } if (finished) return; finished = true; // Swallow the unread body packet if present if (first && request.getContentLengthLong() > 0) { receive(); } // Add the end message if (error) { output(endAndCloseMessageArray, 0, endAndCloseMessageArray.length); } else { output(endMessageArray, 0, endMessageArray.length); } }
/** * Get more request body data from the web server and store it in the * internal buffer. * * @return true if there is more data, false if not. */ protected boolean refillReadBuffer() throws IOException { // If the server returns an empty packet, assume that that end of // the stream has been reached (yuck -- fix protocol??). // FORM support if (replay) { endOfStream = true; // we've read everything there is } if (endOfStream) { return false; } // Request more data immediately output(getBodyMessageArray, 0, getBodyMessageArray.length); boolean moreData = receive(); if( !moreData ) { endOfStream = true; } return moreData; }