<commit_before>// Copyright 2012 <NAME>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package reddit

const (
	UpVote     = "1"
	DownVote   = "-1"
	RemoveVote = "0"
)

var DefaultUserAgent = "github.com/jzelinskie/reddit"<commit_msg>added a helper for http api calls; will make use later<commit_after>// Copyright 2012 <NAME>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package reddit

import (
	"bytes"
	"errors"
	"io/ioutil"
	"net/http"
	"net/url"
)

const (
	UpVote     = "1"
	DownVote   = "-1"
	RemoveVote = "0"
)

var DefaultUserAgent = "github.com/jzelinskie/reddit"

func getResponse(url string, vals *url.Values, s *Session) (*bytes.Buffer, error) {
	// Determine the HTTP action.
	var action, finalurl string
	if vals == nil {
		action = "GET"
		finalurl = url
	} else {
		action = "POST"
		finalurl = url + vals.Encode()
	}

	// Create a request and add the proper headers.
	req, err := http.NewRequest(action, finalurl, nil)
	if err != nil {
		return nil, err
	}
	if s == nil {
		req.AddCookie(s.Cookie)
	}
	req.Header.Set("User-Agent", DefaultUserAgent)

	// Handle the request
	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()
	if resp.StatusCode != http.StatusOK {
		return nil, errors.New(resp.Status)
	}

	respbytes, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return nil, err
	}

	return bytes.NewBuffer(respbytes), nil
}
{'fraction_non_alphanumeric': 0.12468030690537084, 'fraction_numerical': 0.008951406649616368, 'mean_word_length': 3.2994505494505493, 'pattern_counts': {'":': 0, '<': 5, '<?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': '3445024', 'n_tokens_mistral': 574, 'n_tokens_neox': 556, 'n_words': 178}