source/AccessorySDK/Support/HTTPServer.c
OSStatus	HTTPConnectionSendResponse( HTTPConnectionRef inCnx )
{
	HTTPMessageRef const		msg = inCnx->responseMsg;
	OSStatus					err;
	Boolean						run;
	
	check( DebugIsCurrentDispatchQueue( inCnx->queue ) );
	
	err = HTTPHeader_Commit( &msg->header );
	require_noerr( err, exit );
	LogHTTP( inCnx->ucat, inCnx->ucat, msg->header.buf, msg->header.len, msg->bodyPtr, msg->bodyLen );
	
	msg->iov[ 0 ].iov_base = msg->header.buf;
	msg->iov[ 0 ].iov_len  = msg->header.len;
	msg->ion = 1;
	if( msg->bodyLen > 0 )
	{
		msg->iov[ 1 ].iov_base = msg->bodyPtr;
		msg->iov[ 1 ].iov_len  = msg->bodyLen;
		msg->ion = 2;
	}
	msg->iop = msg->iov;
	
	run = ( inCnx->state == kHTTPConnectionStateProcessingRequest );
	inCnx->state = kHTTPConnectionStateWritingResponse;
	if( run ) _HTTPConnectionRunStateMachine( inCnx );
	
exit:
	return( err );
}
//===========================================================================================================================
//	HTTPConnectionSendResponse
//
//	Must be called from the connection queue.
//===========================================================================================================================
HTTPConnectionSendResponse
Must be called from the connection queue.
HTTPConnectionSendResponse Must be called from the connection queue .
OSStatus	HTTPConnectionSendResponse( HTTPConnectionRef inCnx )
{
	HTTPMessageRef const		msg = inCnx->responseMsg;
	OSStatus					err;
	Boolean						run;
	check( DebugIsCurrentDispatchQueue( inCnx->queue ) );
	err = HTTPHeader_Commit( &msg->header );
	require_noerr( err, exit );
	LogHTTP( inCnx->ucat, inCnx->ucat, msg->header.buf, msg->header.len, msg->bodyPtr, msg->bodyLen );
	msg->iov[ 0 ].iov_base = msg->header.buf;
	msg->iov[ 0 ].iov_len  = msg->header.len;
	msg->ion = 1;
	if( msg->bodyLen > 0 )
	{
		msg->iov[ 1 ].iov_base = msg->bodyPtr;
		msg->iov[ 1 ].iov_len  = msg->bodyLen;
		msg->ion = 2;
	}
	msg->iop = msg->iov;
	run = ( inCnx->state == kHTTPConnectionStateProcessingRequest );
	inCnx->state = kHTTPConnectionStateWritingResponse;
	if( run ) _HTTPConnectionRunStateMachine( inCnx );
exit:
	return( err );
}
OSStatus HTTPConnectionSendResponse ( HTTPConnectionRef inCnx ) { HTTPMessageRef const msg = inCnx -> responseMsg ; OSStatus err ; Boolean run ; check ( DebugIsCurrentDispatchQueue ( inCnx -> queue ) ) ; err = HTTPHeader_Commit ( & msg -> header ) ; require_noerr ( err , exit ) ; LogHTTP ( inCnx -> ucat , inCnx -> ucat , msg -> header . buf , msg -> header . len , msg -> bodyPtr , msg -> bodyLen ) ; msg -> iov [ 0 ] . iov_base = msg -> header . buf ; msg -> iov [ 0 ] . iov_len = msg -> header . len ; msg -> ion = 1 ; if ( msg -> bodyLen > 0 ) { msg -> iov [ 1 ] . iov_base = msg -> bodyPtr ; msg -> iov [ 1 ] . iov_len = msg -> bodyLen ; msg -> ion = 2 ; } msg -> iop = msg -> iov ; run = ( inCnx -> state == kHTTPConnectionStateProcessingRequest ) ; inCnx -> state = kHTTPConnectionStateWritingResponse ; if ( run ) _HTTPConnectionRunStateMachine ( inCnx ) ; exit : return ( err ) ; }
HTTPConnectionSendResponse
Must be called from the connection queue.
HTTPConnectionSendResponse Must be called from the connection queue .