private HttpInvalidMessageException checkRequestValidity ( ) { if ( shouldReadResponseImmediately ( ) ) { // ignore body validation as this might happen after sending only // the headers if 100-continue, Upgrade, immediate-read, etc. return null ; } long len = getRequest ( ) . getContentLength ( ) ; long num = getNumBytesWritten ( ) ; if ( HeaderStorage . NOTSET != len && num != len ) { // content-length does not match the number of bytes sent, have to // close the connection since the other end won't be able to read // the body properly if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "Request had content-length of " + len + " but sent " + num ) ; } setPersistent ( false ) ; return new HttpInvalidMessageException ( "Request length " + len + " but sent " + num ) ; } return null ; }
Once we ve fully written the request message do any final checks to verify it s correctness . If something was incorrect then an exception will be handed to the caller and that should be passed along to the application channel above .