<commit_before>package main

import (
	"compress/gzip"
	"encoding/json"
	"fmt"
	"io"
	"io/ioutil"
	"net/http"
	"net/url"
	"strings"
)

var (
	config     *Configuration
	index_html string
)

func main() {
	config = loadConfig("config.json")

	index_html = parseIndexFile("public/index.html")

	http.HandleFunc("/", serveIndexFunc)
	http.HandleFunc("/http-bind/", serveProxyFunc)
	http.Handle("/candy/", http.StripPrefix("/candy/", http.FileServer(http.Dir("./public/candy/"))))

	http.ListenAndServe(fmt.Sprintf("%s:%d", config.App.Host, config.App.Port), nil)
}

func serveIndexFunc(w http.ResponseWriter, r *http.Request) {
	w.Header().Set("Content-Type", "text/html")
	fmt.Fprintf(w, index_html)
}

func serveProxyFunc(w http.ResponseWriter, r *http.Request) {
	target_url, _ := url.Parse(fmt.Sprintf("%s:%d%s",
		config.HTTP_Bind.Host, config.HTTP_Bind.Port, config.HTTP_Bind.Path))

	r.RequestURI = ""
	r.URL = target_url
	r.Host = target_url.Host

	client := &http.Client{}
	response, _ := client.Do(r)

	defer response.Body.Close()

	var reader io.ReadCloser
	switch response.Header.Get("Content-Encoding") {
	case "gzip":
		reader, _ = gzip.NewReader(response.Body)
		defer reader.Close()<commit_msg>parse proxy target URL only once<commit_after>package main

import (
	"compress/gzip"
	"encoding/json"
	"fmt"
	"io"
	"io/ioutil"
	"net/http"
	"net/url"
	"strings"
)

var (
	config     *Configuration
	index_html string
	proxy_target *url.URL
)

func main() {
	config = loadConfig("config.json")

	index_html = parseIndexFile("public/index.html")
	proxy_target, _ = url.Parse(fmt.Sprintf("%s:%d%s",
		config.HTTP_Bind.Host, config.HTTP_Bind.Port, config.HTTP_Bind.Path))

	http.HandleFunc("/", serveIndexFunc)
	http.HandleFunc("/http-bind/", serveProxyFunc)
	http.Handle("/candy/", http.StripPrefix("/candy/", http.FileServer(http.Dir("./public/candy/"))))

	http.ListenAndServe(fmt.Sprintf("%s:%d", config.App.Host, config.App.Port), nil)
}

func serveIndexFunc(w http.ResponseWriter, r *http.Request) {
	w.Header().Set("Content-Type", "text/html")
	fmt.Fprintf(w, index_html)
}

func serveProxyFunc(w http.ResponseWriter, r *http.Request) {
	r.RequestURI = ""
	r.URL = proxy_target
	r.Host = proxy_target.Host

	client := &http.Client{}
	response, _ := client.Do(r)

	defer response.Body.Close()

	var reader io.ReadCloser
	switch response.Header.Get("Content-Encoding") {
	case "gzip":
		reader, _ = gzip.NewReader(response.Body)
		defer reader.Close()
{'fraction_non_alphanumeric': 0.17113821138211383, 'fraction_numerical': 0.0, 'mean_word_length': 4.736596736596737, 'pattern_counts': {'":': 2, '<': 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': '1926424', 'n_tokens_mistral': 930, 'n_tokens_neox': 912, 'n_words': 154}