<commit_before>package main

import (
	"fmt"
	"log"
	"net/http"
	"os"
	"strconv"
)

func RouteHandler() http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		// Write it back to the client.
		log.Println("[RouteHandler]", r.Method, r.URL, r.UserAgent())
		fmt.Fprintf(w, "howdy")
	})
}

func main() {
	port := 8080
	portstring := strconv.Itoa(port)

	http.Handle("/", RouteHandler())

	log.Println("Starting GO webserver on port", portstring)
	err := http.ListenAndServe(":"+portstring, nil)
	if err != nil {
		log.Fatal("ListenAndServe error: ", err)
		os.Exit(1)
	}
}
<commit_msg>Got basic proxy working<commit_after>package main

import (
	"flag"
	"fmt"
	"io/ioutil"
	"log"
	"net/http"
	"os"
)

var target *string

func main() {
	target = flag.String("target", "http://stackoverflow.com", "target URL for reverse proxy")
	flag.Parse()
	http.HandleFunc("/", report)
	log.Fatal(http.ListenAndServe("127.0.0.1:8080", nil))
}

func report(w http.ResponseWriter, r *http.Request) {

	uri := *target + r.RequestURI

	fmt.Println(r.Method + ": " + uri)

	if r.Method == "POST" {
		body, err := ioutil.ReadAll(r.Body)
		fatal(err)
		fmt.Printf("Body: %v\n", string(body))
	}

	rr, err := http.NewRequest(r.Method, uri, r.Body)
	fatal(err)
	copyHeader(r.Header, &rr.Header)

	// Create a client and query the target
	var transport http.Transport
	resp, err := transport.RoundTrip(rr)
	fatal(err)

	fmt.Printf("Resp-Headers: %v\n", resp.Header)

	defer resp.Body.Close()
	body, err := ioutil.ReadAll(resp.Body)
	fatal(err)

	dH := w.Header()
	copyHeader(resp.Header, &dH)
	dH.Add("Requested-Host", rr.Host)

	w.Write(body)
}

func fatal(err error) {
	if err != nil {
		log.Fatal(err)
		os.Exit(1)
	}
}

func copyHeader(source http.Header, dest *http.Header) {
	for n, v := range source {
		for _, vv := range v {
			dest.Add(n, vv)
		}
	}
}

{'fraction_non_alphanumeric': 0.17549491706795078, 'fraction_numerical': 0.008560727661851257, 'mean_word_length': 3.882506527415144, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, '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': '5234334', 'n_tokens_mistral': 786, 'n_tokens_neox': 745, 'n_words': 164}