function formDataPolicy() {
    return {
        name: formDataPolicyName,
        async sendRequest(request, next) {
            if (request.formData) {
                const formData = request.formData;
                const requestForm = new FormData();
                for (const formKey of Object.keys(formData)) {
                    const formValue = formData[formKey];
                    if (Array.isArray(formValue)) {
                        for (const subValue of formValue) {
                            requestForm.append(formKey, subValue);
                        }
                    }
                    else {
                        requestForm.append(formKey, formValue);
                    }
                }
                request.body = requestForm;
                request.formData = undefined;
                const contentType = request.headers.get("Content-Type");
                if (contentType && contentType.indexOf("multipart/form-data") !== -1) {
                    // browser will automatically apply a suitable content-type header
                    request.headers.delete("Content-Type");
                }
            }
            return next(request);
        }
    };
}
/**
 * A policy that encodes FormData on the request into the body.
 */
A policy that encodes FormData on the request into the body.
A policy that encodes FormData on the request into the body .
function formDataPolicy() {
    return {
        name: formDataPolicyName,
        async sendRequest(request, next) {
            if (request.formData) {
                const formData = request.formData;
                const requestForm = new FormData();
                for (const formKey of Object.keys(formData)) {
                    const formValue = formData[formKey];
                    if (Array.isArray(formValue)) {
                        for (const subValue of formValue) {
                            requestForm.append(formKey, subValue);
                        }
                    }
                    else {
                        requestForm.append(formKey, formValue);
                    }
                }
                request.body = requestForm;
                request.formData = undefined;
                const contentType = request.headers.get("Content-Type");
                if (contentType && contentType.indexOf("multipart/form-data") !== -1) {
                    request.headers.delete("Content-Type");
                }
            }
            return next(request);
        }
    };
}
function formDataPolicy ( ) { return { name : formDataPolicyName , async sendRequest ( request , next ) { if ( request . formData ) { const formData = request . formData ; const requestForm = new FormData ( ) ; for ( const formKey of Object . keys ( formData ) ) { const formValue = formData [ formKey ] ; if ( Array . isArray ( formValue ) ) { for ( const subValue of formValue ) { requestForm . append ( formKey , subValue ) ; } } else { requestForm . append ( formKey , formValue ) ; } } request . body = requestForm ; request . formData = undefined ; const contentType = request . headers . get ( "Content-Type" ) ; if ( contentType && contentType . indexOf ( "multipart/form-data" ) !== - 1 ) { request . headers . delete ( "Content-Type" ) ; } } return next ( request ) ; } } ; }
A policy that encodes FormData on the request into the body.
A policy that encodes FormData on the request into the body .
// browser will automatically apply a suitable content-type header