<commit_before>package main

import (
	"flag"
	"io"
	"io/ioutil"
	"log"
	"net/http"
	"os"
	"path/filepath"

	"code.google.com/p/goconf/conf" // new bsd
)

func init() {
}

func Handler(w http.ResponseWriter, r *http.Request) {
	if r.Method != "POST" {
		http.Error(w, "Only POST allowed", http.StatusForbidden)
		return
	}
	if r.URL.Path != "/" {
		http.Error(w, "Only / allowed as path", http.StatusForbidden)
		return
	}
	hostname := r.Header.Get(HTTP_HOST_HEADER)
	if hostname == "" {
		http.Error(w, "No hostname header given", http.StatusForbidden)
		return
	}

	tmpfile, err := ioutil.TempFile(SPOOL_DIR, PREFIX)
	if err != nil {
		log.Printf("Error writing spool file: ", err)
		http.Error(w, "Error writing spool file", http.StatusInternalServerError)
		return
	}
	tmpfile_name := tmpfile.Name()
	defer os.Remove(tmpfile_name)

	target_name, ok := createSpoolFilePath(SPOOL_DIR, PREFIX+hostname)
	if !ok {
		log.Printf("Error: invalid spool filename, escapes spool directory - %q", target_name)
		http.Error(w, "Error invalid spool filename", http.StatusInternalServerError)
		return
	}

	body_len, err := io.Copy(tmpfile, r.Body)
	if DEBUG {
		log.Printf("Read %d bytes for %q -> %s\n", body_len, hostname, target_name)
	}
	tmpfile.Close()

	if err := os.Chmod(tmpfile_name, 0660); err != nil {
		log.Printf("Error changing permission: ", err)
	}
	if err := os.Rename(tmpfile_name, target_name); err != nil {
		log.Printf("Error renaming file: ", err)<commit_msg>fix log output<commit_after>package main

import (
	"flag"
	"io"
	"io/ioutil"
	"log"
	"net/http"
	"os"
	"path/filepath"

	"code.google.com/p/goconf/conf" // new bsd
)

func init() {
}

func Handler(w http.ResponseWriter, r *http.Request) {
	if r.Method != "POST" {
		http.Error(w, "Only POST allowed", http.StatusForbidden)
		return
	}
	if r.URL.Path != "/" {
		http.Error(w, "Only / allowed as path", http.StatusForbidden)
		return
	}
	hostname := r.Header.Get(HTTP_HOST_HEADER)
	if hostname == "" {
		http.Error(w, "No hostname header given", http.StatusForbidden)
		return
	}

	tmpfile, err := ioutil.TempFile(SPOOL_DIR, PREFIX)
	if err != nil {
		log.Println("Error writing spool file: ", err)
		http.Error(w, "Error writing spool file", http.StatusInternalServerError)
		return
	}
	tmpfile_name := tmpfile.Name()
	defer os.Remove(tmpfile_name)

	target_name, ok := createSpoolFilePath(SPOOL_DIR, PREFIX+hostname)
	if !ok {
		log.Printf("Error: invalid spool filename, escapes spool directory - %q", target_name)
		http.Error(w, "Error invalid spool filename", http.StatusInternalServerError)
		return
	}

	body_len, err := io.Copy(tmpfile, r.Body)
	if DEBUG {
		log.Printf("Read %d bytes for %q -> %s\n", body_len, hostname, target_name)
	}
	tmpfile.Close()

	if err := os.Chmod(tmpfile_name, 0660); err != nil {
		log.Println("Error changing permission: ", err)
	}
	if err := os.Rename(tmpfile_name, target_name); err != nil {
		log.Println("Error renaming file: ", err)
{'fraction_non_alphanumeric': 0.1485753052917232, 'fraction_numerical': 0.0027137042062415195, 'mean_word_length': 4.1646234676007, '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': '4448607', 'n_tokens_mistral': 1166, 'n_tokens_neox': 1125, 'n_words': 261}