<commit_before>package httpclient

import (
	"net/http"
	"encoding/json"
	//
	"golang.org/x/net/context"
	"google.golang.org/appengine/urlfetch"
	//
	"github.com/dghubble/sling"
)

type Client struct {
	httpClient *http.Client
}

func NewClient() *Client {
	return &Client{
		&http.Client{},
	}
}

func NewUrlfetchClient(ctx context.Context) *Client {

	return &Client{
		urlfetch.Client(ctx),
	}
}

func (client *Client) New(httpRequest *http.Request) *Request {
	return &Request{
		client,
		httpRequest,
		1,
		"200",
	}
}

func (client *Client) Get(url string, dst interface{}, headers ...map[string]string) ([]byte, error) {

	httpRequest, err := sling.New().Get(url).Request()
	if err != nil {
		return nil, err
	}

	for _, header := range headers {
		for k, v := range header {
			httpRequest.Header.Set(k, v)
		}
	}

	b, err := client.New(httpRequest).Do()
	if err != nil {
		return nil, err
	}

	if dst != nil {
		err = json.Unmarshal(b, dst)
		if err != nil {
			return nil, err
		}
		return nil, nil
	}

	return b, nil
}

func (client *Client) Post(url string, src, dst interface{}, headers ...map[string]string) ([]byte, error) {

	httpRequest, err := sling.New().Get(url).BodyJSON(src).Request()
	if err != nil {
		return nil, err
	}

	for _, header := range headers {
		for k, v := range header {
			httpRequest.Header.Set(k, v)
		}
	}

	b, err := client.New(httpRequest).Do()
	if err != nil {
		return nil, err
	}

	if dst != nil {
		err = json.Unmarshal(b, dst)
		if err != nil {
			return nil, err
		}
		return nil, nil
	}

	return b, nil
}

func (client *Client) Delete(url string, src interface{}, headers ...map[string]string) ([]byte, error) {

	httpRequest, err := sling.New().Get(url).BodyJSON(src).Request()
	if err != nil {
		return nil, err
	}

	for _, header := range headers {
		for k, v := range header {
			httpRequest.Header.Set(k, v)
		}
	}

	b, err := client.New(httpRequest).Do()
	if err != nil {
		return nil, err
	}

	return b, nil
}<commit_msg>fix post, delete requests<commit_after>package httpclient

import (
	"net/http"
	"encoding/json"
	//
	"golang.org/x/net/context"
	"google.golang.org/appengine/urlfetch"
	//
	"github.com/dghubble/sling"
)

type Client struct {
	httpClient *http.Client
}

func NewClient() *Client {
	return &Client{
		&http.Client{},
	}
}

func NewUrlfetchClient(ctx context.Context) *Client {

	return &Client{
		urlfetch.Client(ctx),
	}
}

func (client *Client) New(httpRequest *http.Request) *Request {
	return &Request{
		client,
		httpRequest,
		1,
		"200",
	}
}

func (client *Client) Get(url string, dst interface{}, headers ...map[string]string) ([]byte, error) {

	httpRequest, err := sling.New().Get(url).Request()
	if err != nil {
		return nil, err
	}

	for _, header := range headers {
		for k, v := range header {
			httpRequest.Header.Set(k, v)
		}
	}

	b, err := client.New(httpRequest).Do()
	if err != nil {
		return nil, err
	}

	if dst != nil {
		err = json.Unmarshal(b, dst)
		if err != nil {
			return nil, err
		}
		return nil, nil
	}

	return b, nil
}

func (client *Client) Post(url string, src, dst interface{}, headers ...map[string]string) ([]byte, error) {

	httpRequest, err := sling.New().Post(url).BodyJSON(src).Request()
	if err != nil {
		return nil, err
	}

	for _, header := range headers {
		for k, v := range header {
			httpRequest.Header.Set(k, v)
		}
	}

	b, err := client.New(httpRequest).Do()
	if err != nil {
		return nil, err
	}

	if dst != nil {
		err = json.Unmarshal(b, dst)
		if err != nil {
			return nil, err
		}
		return nil, nil
	}

	return b, nil
}

func (client *Client) Delete(url string, src interface{}, headers ...map[string]string) ([]byte, error) {

	httpRequest, err := sling.New().Delete(url).BodyJSON(src).Request()
	if err != nil {
		return nil, err
	}

	for _, header := range headers {
		for k, v := range header {
			httpRequest.Header.Set(k, v)
		}
	}

	b, err := client.New(httpRequest).Do()
	if err != nil {
		return nil, err
	}

	return b, nil
}
{'fraction_non_alphanumeric': 0.16214177978883862, 'fraction_numerical': 0.002011060834590246, 'mean_word_length': 3.2329787234042553, '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': '3701121', 'n_tokens_mistral': 1589, 'n_tokens_neox': 1469, 'n_words': 399}