<commit_before>package common

import (
	"fmt"
	"net/http"
	"net"
	"time"
)

var USER_AGENT = fmt.Sprintf("Filestash/%s.%s (http://filestash.app)", APP_VERSION, BUILD_NUMBER)

var HTTPClient = http.Client{
	Timeout: 5 * time.Hour,
	Transport: NewTransormedTransport(http.Transport{
		Dial: (&net.Dialer{
			Timeout:   10 * time.Second,
			KeepAlive: 10 * time.Second,
		}).Dial,
		TLSHandshakeTimeout:   5 * time.Second,
		IdleConnTimeout:       60 * time.Second,
		ResponseHeaderTimeout: 60 * time.Second,
	}),
}

var HTTP = http.Client{
	Timeout: 10000 * time.Millisecond,
	Transport: NewTransormedTransport(http.Transport{
		Dial: (&net.Dialer{
			Timeout:   5000 * time.Millisecond,
			KeepAlive: 5000 * time.Millisecond,
		}).Dial,
		TLSHandshakeTimeout:   5000 * time.Millisecond,
		IdleConnTimeout:       5000 * time.Millisecond,
		ResponseHeaderTimeout: 5000 * time.Millisecond,
	}),
}

func NewTransormedTransport(transport http.Transport) http.RoundTripper {
	return &transformedTransport{ &transport }
}
type transformedTransport struct {
	original http.RoundTripper
}
func (this *transformedTransport) RoundTrip(req *http.Request) (*http.Response, error) {
	req.Header.Add("User-Agent", USER_AGENT)
	return this.original.RoundTrip(req)
}<commit_msg>improve (http): cleanup code<commit_after>package common

import (
	"fmt"
	"net/http"
	"net"
	"time"
)

var USER_AGENT = fmt.Sprintf("Filestash/%s.%s (http://filestash.app)", APP_VERSION, BUILD_NUMBER)

var HTTPClient = http.Client{
	Timeout: 5 * time.Hour,
	Transport: NewTransormedTransport(http.Transport{
		Dial: (&net.Dialer{
			Timeout:   10 * time.Second,
			KeepAlive: 10 * time.Second,
		}).Dial,
		TLSHandshakeTimeout:   5 * time.Second,
		IdleConnTimeout:       60 * time.Second,
		ResponseHeaderTimeout: 60 * time.Second,
	}),
}

var HTTP = http.Client{
	Timeout: 10000 * time.Millisecond,
	Transport: NewTransormedTransport(http.Transport{
		Dial: (&net.Dialer{
			Timeout:   5000 * time.Millisecond,
			KeepAlive: 5000 * time.Millisecond,
		}).Dial,
		TLSHandshakeTimeout:   5000 * time.Millisecond,
		IdleConnTimeout:       5000 * time.Millisecond,
		ResponseHeaderTimeout: 5000 * time.Millisecond,
	}),
}

func NewTransormedTransport(transport http.Transport) http.RoundTripper {
	return &TransformedTransport{ &transport }
}
type TransformedTransport struct {
	Orig http.RoundTripper
}
func (this *TransformedTransport) RoundTrip(req *http.Request) (*http.Response, error) {
	req.Header.Add("User-Agent", USER_AGENT)
	return this.Orig.RoundTrip(req)
}
{'fraction_non_alphanumeric': 0.1269276393831554, 'fraction_numerical': 0.0276789244760775, 'mean_word_length': 4.622222222222222, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2849970', 'n_tokens_mistral': 975, 'n_tokens_neox': 871, 'n_words': 179}