/** * <p>Non-Blocking write, committing the response if needed.</p> * * @param content the content buffer to write * @param complete whether the content is complete for the response * @param callback Callback when complete or failed */ protected void write(ByteBuffer content, boolean complete, Callback callback) { sendResponse(null,content,complete,callback); }
/** * <p>Non-Blocking write, committing the response if needed.</p> * Called as last link in HttpOutput.Filter chain * @param content the content buffer to write * @param complete whether the content is complete for the response * @param callback Callback when complete or failed */ @Override public void write(ByteBuffer content, boolean complete, Callback callback) { _written+=BufferUtil.length(content); sendResponse(null,content,complete,callback); }
/** * <p>Non-Blocking write, committing the response if needed.</p> * Called as last link in HttpOutput.Filter chain * @param content the content buffer to write * @param complete whether the content is complete for the response * @param callback Callback when complete or failed */ @Override public void write(ByteBuffer content, boolean complete, Callback callback) { _written+=BufferUtil.length(content); sendResponse(null,content,complete,callback); }
/** * Sends a 102-Processing response. * If the connection is a HTTP connection, the version is 1.1 and the * request has a Expect header starting with 102, then a 102 response is * sent. This indicates that the request still be processed and real response * can still be sent. This method is called by sendError if it is passed 102. * @see javax.servlet.http.HttpServletResponse#sendError(int) */ public void sendProcessing() throws IOException { if (_channel.isExpecting102Processing() && !isCommitted()) { _channel.sendResponse(HttpGenerator.PROGRESS_102_INFO, null, true); } }
/** * Sends a 102-Processing response. * If the connection is a HTTP connection, the version is 1.1 and the * request has a Expect header starting with 102, then a 102 response is * sent. This indicates that the request still be processed and real response * can still be sent. This method is called by sendError if it is passed 102. * @throws IOException if unable to send the 102 response * @see javax.servlet.http.HttpServletResponse#sendError(int) */ public void sendProcessing() throws IOException { if (_channel.isExpecting102Processing() && !isCommitted()) { _channel.sendResponse(HttpGenerator.PROGRESS_102_INFO, null, true); } }
/** * Sends a 102-Processing response. * If the connection is a HTTP connection, the version is 1.1 and the * request has a Expect header starting with 102, then a 102 response is * sent. This indicates that the request still be processed and real response * can still be sent. This method is called by sendError if it is passed 102. * @throws IOException if unable to send the 102 response * @see javax.servlet.http.HttpServletResponse#sendError(int) */ public void sendProcessing() throws IOException { if (_channel.isExpecting102Processing() && !isCommitted()) { _channel.sendResponse(HttpGenerator.PROGRESS_102_INFO, null, true); } }
/** * Sends a 102-Processing response. * If the connection is a HTTP connection, the version is 1.1 and the * request has a Expect header starting with 102, then a 102 response is * sent. This indicates that the request still be processed and real response * can still be sent. This method is called by sendError if it is passed 102. * @throws IOException if unable to send the 102 response * @see javax.servlet.http.HttpServletResponse#sendError(int) */ public void sendProcessing() throws IOException { if (_channel.isExpecting102Processing() && !isCommitted()) { _channel.sendResponse(HttpGenerator.PROGRESS_102_INFO, null, true); } }
/** * If the associated response has the Expect header set to 100 Continue, * then accessing the input stream indicates that the handler/servlet * is ready for the request body and thus a 100 Continue response is sent. * * @throws IOException if the InputStream cannot be created */ public void continue100(int available) throws IOException { // If the client is expecting 100 CONTINUE, then send it now. // TODO: consider using an AtomicBoolean ? if (isExpecting100Continue()) { _expect100Continue = false; // is content missing? if (available == 0) { if (_response.isCommitted()) throw new IOException("Committed before 100 Continues"); // TODO: break this dependency with HttpGenerator boolean committed = sendResponse(HttpGenerator.CONTINUE_100_INFO, null, false); if (!committed) throw new IOException("Concurrent commit while trying to send 100-Continue"); } } }
protected boolean sendResponse(ResponseInfo info, ByteBuffer content, boolean complete) throws IOException { try(Blocker blocker = _response.getHttpOutput().acquireWriteBlockingCallback()) { boolean committing = sendResponse(info,content,complete,blocker); blocker.block(); return committing; } }
protected boolean sendResponse(MetaData.Response info, ByteBuffer content, boolean complete) throws IOException { try(Blocker blocker = _response.getHttpOutput().acquireWriteBlockingCallback()) { boolean committing = sendResponse(info,content,complete,blocker); blocker.block(); return committing; } catch (Throwable failure) { if (LOG.isDebugEnabled()) LOG.debug(failure); abort(failure); throw failure; } }
public boolean sendResponse(MetaData.Response info, ByteBuffer content, boolean complete) throws IOException { try(Blocker blocker = _response.getHttpOutput().acquireWriteBlockingCallback()) { boolean committing = sendResponse(info,content,complete,blocker); blocker.block(); return committing; } catch (Throwable failure) { if (LOG.isDebugEnabled()) LOG.debug(failure); abort(failure); throw failure; } }
@Override public void badMessage(int status, String reason) { if (status < 400 || status > 599) status = HttpStatus.BAD_REQUEST_400; try { if (_state.handling()==Action.REQUEST_DISPATCH) { ByteBuffer content=null; HttpFields fields=new HttpFields(); ErrorHandler handler=getServer().getBean(ErrorHandler.class); if (handler!=null) content=handler.badMessageError(status,reason,fields); sendResponse(new ResponseInfo(HttpVersion.HTTP_1_1,fields,0,status,reason,false),content ,true); } } catch (IOException e) { LOG.debug(e); } finally { if (_state.unhandle()==Action.COMPLETE) _state.completed(); else throw new IllegalStateException(); } }
content=handler.badMessageError(status,reason,fields); sendResponse(new MetaData.Response(HttpVersion.HTTP_1_1,status,reason,fields,BufferUtil.length(content)),content ,true);
fields.add(HttpHeader.CONNECTION,HttpHeaderValue.CLOSE); ResponseInfo info = new ResponseInfo(_request.getHttpVersion(), fields, 0, HttpStatus.INTERNAL_SERVER_ERROR_500, null, _request.isHead()); boolean committed = sendResponse(info, null, true); if (!committed) LOG.warn("Could not send response error 500: "+x);
content=handler.badMessageError(status,reason,fields); sendResponse(new MetaData.Response(HttpVersion.HTTP_1_1,status,reason,fields,BufferUtil.length(content)),content ,true);