<commit_before>package gogobosh

import (
	"crypto/tls"
	"errors"
	"fmt"
	"net/http"
	"net/http/httputil"
	"regexp"
	"strings"
)

const (
	PRIVATE_DATA_PLACEHOLDER = "[PRIVATE DATA HIDDEN]"
)

func newHttpClient() *http.Client {
	tr := &http.Transport{
		TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
		Proxy:           http.ProxyFromEnvironment,
	}
	return &http.Client{
		Transport:     tr,
		CheckRedirect: PrepareRedirect,
	}
}

func PrepareRedirect(req *http.Request, via []*http.Request) error {
	if len(via) > 1 {
		return errors.New("stopped after 1 redirect")
	}

	prevReq := via[len(via)-1]

	req.Header.Set("Authorization", prevReq.Header.Get("Authorization"))

	dumpRequest(req)

	return nil
}<commit_msg>bosh doesn't return :25555 in its redirect Location; so explicitly pass Host on redirections<commit_after>package gogobosh

import (
	"crypto/tls"
	"errors"
	"fmt"
	"net/http"
	"net/http/httputil"
	"regexp"
	"strings"
)

const (
	PRIVATE_DATA_PLACEHOLDER = "[PRIVATE DATA HIDDEN]"
)

func newHttpClient() *http.Client {
	tr := &http.Transport{
		TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
		Proxy:           http.ProxyFromEnvironment,
	}
	return &http.Client{
		Transport:     tr,
		CheckRedirect: PrepareRedirect,
	}
}

func PrepareRedirect(req *http.Request, via []*http.Request) error {
	if len(via) > 1 {
		return errors.New("stopped after 1 redirect")
	}

	prevReq := via[len(via)-1]

	/* Ensure redirect includes original IP:PORT & Authorization */
	req.URL.Host = prevReq.URL.Host
	req.Host = prevReq.Host
	req.Header.Set("Authorization", prevReq.Header.Get("Authorization"))
	req.Header.Set("Accept", prevReq.Header.Get("Accept"))
	req.Header.Set("Content-Type", prevReq.Header.Get("Content-Type"))
	req.Header.Set("User-Agent", prevReq.Header.Get("User-Agent"))

	dumpRequest(req)

	return nil
}
{'fraction_non_alphanumeric': 0.1442516268980477, 'fraction_numerical': 0.00596529284164859, 'mean_word_length': 4.54054054054054, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1946325', 'n_tokens_mistral': 688, 'n_tokens_neox': 662, 'n_words': 133}