<commit_before>import { ProxyUtils } from '../utils';
import { IProxyContext, IProxySettings } from '../interfaces';
import { ISPRequest } from 'sp-request';
import { IAuthResponse } from 'node-sp-auth';
import { Request, Response, NextFunction } from 'express';

export class SoapRouter {

    private spr: ISPRequest;
    private ctx: IProxyContext;
    private settings: IProxySettings;
    private util: ProxyUtils;

    constructor(context: IProxyContext, settings: IProxySettings) {
        this.ctx = context;
        this.settings = settings;
        this.util = new ProxyUtils(this.ctx);
    }

    public router = (req: Request, res: Response, next?: NextFunction) => {
        let endpointUrl = this.util.buildEndpointUrl(req.originalUrl);
        this.spr = this.util.getCachedRequest(this.spr);

        if (!this.settings.silentMode) {
            console.log('\nPOST: ' + endpointUrl);
        }

        let regExpOrigin = new RegExp(req.headers.origin, 'g');
        let soapBody = '';
        req.on('data', (chunk) => {
            soapBody += chunk;
        });
        req.on('end', () => {
            soapBody = soapBody.replace(regExpOrigin, this.ctx.siteUrl);<commit_msg>SOAP request origin replace issue fix<commit_after>import { ProxyUtils } from '../utils';
import { IProxyContext, IProxySettings } from '../interfaces';
import { ISPRequest } from 'sp-request';
import { IAuthResponse } from 'node-sp-auth';
import { Request, Response, NextFunction } from 'express';

export class SoapRouter {

    private spr: ISPRequest;
    private ctx: IProxyContext;
    private settings: IProxySettings;
    private util: ProxyUtils;

    constructor(context: IProxyContext, settings: IProxySettings) {
        this.ctx = context;
        this.settings = settings;
        this.util = new ProxyUtils(this.ctx);
    }

    public router = (req: Request, res: Response, next?: NextFunction) => {
        let endpointUrl = this.util.buildEndpointUrl(req.originalUrl);
        this.spr = this.util.getCachedRequest(this.spr);

        if (!this.settings.silentMode) {
            console.log('\nPOST: ' + endpointUrl);
        }

        let soapBody = '';
        req.on('data', (chunk) => {
            soapBody += chunk;
        });
        req.on('end', () => {
            if (req.headers.origin) {
                let regExpOrigin = new RegExp(req.headers.origin, 'g');
                soapBody = soapBody.replace(regExpOrigin, this.ctx.siteUrl);
            }
{'fraction_non_alphanumeric': 0.12983870967741937, 'fraction_numerical': 0.0, 'mean_word_length': 2.6810089020771515, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3056620', 'n_tokens_mistral': 715, 'n_tokens_neox': 702, 'n_words': 168}