protected void sendAndReceive(HttpMessage message, boolean isFollowRedirect, boolean handleAntiCSRF) throws IOException {

        if (parent.handleAntiCsrfTokens() && handleAntiCSRF) {
            if (extAntiCSRF == null) {
                extAntiCSRF = Control.getSingleton().getExtensionLoader().getExtension(ExtensionAntiCSRF.class);
            }
            if (extAntiCSRF != null) {
                List<AntiCsrfToken> tokens = extAntiCSRF.getTokens(message);
                AntiCsrfToken antiCsrfToken = null;
                if (tokens.size() > 0) {
                    antiCsrfToken = tokens.get(0);
                }

                if (antiCsrfToken != null) {
                    regenerateAntiCsrfToken(message, antiCsrfToken);
                }
            }
        }

        if (this.parent.getScannerParam().isInjectPluginIdInHeader()) {
    		this.msg.getRequestHeader().setHeader(HttpHeader.X_ZAP_SCAN_ID, Integer.toString(getId()));
    	}

        // always get the fresh copy
        message.getRequestHeader().setHeader(HttpHeader.IF_MODIFIED_SINCE, null);
        message.getRequestHeader().setHeader(HttpHeader.IF_NONE_MATCH, null);
        message.getRequestHeader().setContentLength(message.getRequestBody().length());

        if (this.getDelayInMs() > 0) {
            try {
                Thread.sleep(this.getDelayInMs());
            } catch (InterruptedException e) {
                // Ignore
            }
        }
        
        //ZAP: Runs the "beforeScan" methods of any ScannerHooks
        parent.performScannerHookBeforeScan(message, this);

        if (isFollowRedirect) {
            parent.getHttpSender().sendAndReceive(message, getParent().getRedirectRequestConfig());
        } else {
            parent.getHttpSender().sendAndReceive(message, false);
        }
        
        // ZAP: Notify parent
        parent.notifyNewMessage(this, message);
        
        //ZAP: Set the history reference back and run the "afterScan" methods of any ScannerHooks
        parent.performScannerHookAfterScan(message, this);
    }
protected void sendAndReceive ( HttpMessage message , boolean isFollowRedirect , boolean handleAntiCSRF ) throws IOException { if ( parent . handleAntiCsrfTokens ( ) && handleAntiCSRF ) { if ( extAntiCSRF == null ) { extAntiCSRF = Control . getSingleton ( ) . getExtensionLoader ( ) . getExtension ( ExtensionAntiCSRF . class ) ; } if ( extAntiCSRF != null ) { List < AntiCsrfToken > tokens = extAntiCSRF . getTokens ( message ) ; AntiCsrfToken antiCsrfToken = null ; if ( tokens . size ( ) > 0 ) { antiCsrfToken = tokens . get ( 0 ) ; } if ( antiCsrfToken != null ) { regenerateAntiCsrfToken ( message , antiCsrfToken ) ; } } } if ( this . parent . getScannerParam ( ) . isInjectPluginIdInHeader ( ) ) { this . msg . getRequestHeader ( ) . setHeader ( HttpHeader . X_ZAP_SCAN_ID , Integer . toString ( getId ( ) ) ) ; } message . getRequestHeader ( ) . setHeader ( HttpHeader . IF_MODIFIED_SINCE , null ) ; message . getRequestHeader ( ) . setHeader ( HttpHeader . IF_NONE_MATCH , null ) ; message . getRequestHeader ( ) . setContentLength ( message . getRequestBody ( ) . length ( ) ) ; if ( this . getDelayInMs ( ) > 0 ) { try { Thread . sleep ( this . getDelayInMs ( ) ) ; } catch ( InterruptedException e ) { } } parent . performScannerHookBeforeScan ( message , this ) ; if ( isFollowRedirect ) { parent . getHttpSender ( ) . sendAndReceive ( message , getParent ( ) . getRedirectRequestConfig ( ) ) ; } else { parent . getHttpSender ( ) . sendAndReceive ( message , false ) ; } parent . notifyNewMessage ( this , message ) ; parent . performScannerHookAfterScan ( message , this ) ; }
Sends and receives the given {@code message}, optionally following redirections and optionally regenerating anti-CSRF
token, if any.
<p>
The following changes are made to the request before being sent:
<ul>
<li>The request headers {@link HttpHeader#IF_MODIFIED_SINCE} and {@link HttpHeader#IF_NONE_MATCH} are removed, to always
obtain a fresh response;</li>
<li>The header {@link HttpHeader#CONTENT_LENGTH} is updated, to match the length of the request body.</li>
<li>Changes done by {@link org.zaproxy.zap.network.HttpSenderListener HttpSenderListener} (for example, scripts).</li>
</ul>

@param message the message to be sent and received
@param isFollowRedirect {@code true} if redirections should be followed, {@code false} otherwise
@param handleAntiCSRF {@code true} if the anti-CSRF token present in the request should be handled/regenerated,
{@code false} otherwise
@throws HttpException if a HTTP error occurred
@throws IOException if an I/O error occurred (for example, read time out)
@see #sendAndReceive(HttpMessage)
@see #sendAndReceive(HttpMessage, boolean)