<commit_before>package multipartbuilder

import (
	"bytes"
	"fmt"
	"io"
	"mime/multipart"
	"net/http"
	"os"
	"path/filepath"
)

// Builder represents HTTP multipart request builder.
//
// It is not thread-safe.
type Builder interface {

	// WriteField writes field.
	//
	// This method returns current Builder for chaining.
	WriteField(name string, value string) Builder

	// WriteFields writes multiple fields.
	// It is intended to work with net/url.Values.
	//
	// This method returns current Builder for chaining.
	WriteFields(fields map[string][]string) Builder

	// SlurpFile reads filePath as fieldName.
	//
	// This method returns current Builder for chaining.
	SlurpFile(fieldName, filePath string) Builder

	// SlurpReader reads reader as fieldName with fileName.
	//
	// This method returns current Builder for chaining.
	SlurpReader(fieldName, fileName string, reader io.Reader) Builder

	// Build finalizes builder and returns Content-Type and multipart body reader.
	//
	// It does not check, if is called multiple times, so be careful.
	Build() (contentType string, body io.Reader, err error)

	// BuildRequest is a convenience method for creating HTTP request from builder.
	// It is just a wrapper for .Build() method.
	//
	// It does not check, if is called multiple times, so be careful.
	BuildRequest(method string, url string) (*http.Request, error)
}

func New() Builder {
	body := bytes.NewBuffer(nil)
	return &builder{
		body: body,
		form: multipart.NewWriter(body),
	}
}

// ----------------------------------------------------------------------------
<commit_msg>Added godoc comment for New() constructor<commit_after>package multipartbuilder

import (
	"bytes"
	"fmt"
	"io"
	"mime/multipart"
	"net/http"
	"os"
	"path/filepath"
)

// Builder represents HTTP multipart request builder.
//
// It is not thread-safe.
type Builder interface {

	// WriteField writes field.
	//
	// This method returns current Builder for chaining.
	WriteField(name string, value string) Builder

	// WriteFields writes multiple fields.
	// It is intended to work with net/url.Values.
	//
	// This method returns current Builder for chaining.
	WriteFields(fields map[string][]string) Builder

	// SlurpFile reads filePath as fieldName.
	//
	// This method returns current Builder for chaining.
	SlurpFile(fieldName, filePath string) Builder

	// SlurpReader reads reader as fieldName with fileName.
	//
	// This method returns current Builder for chaining.
	SlurpReader(fieldName, fileName string, reader io.Reader) Builder

	// Build finalizes builder and returns Content-Type and multipart body reader.
	//
	// It does not check, if is called multiple times, so be careful.
	Build() (contentType string, body io.Reader, err error)

	// BuildRequest is a convenience method for creating HTTP request from builder.
	// It is just a wrapper for .Build() method.
	//
	// It does not check, if is called multiple times, so be careful.
	BuildRequest(method string, url string) (*http.Request, error)
}

// New constructs new multipart Builder.
func New() Builder {
	body := bytes.NewBuffer(nil)
	return &builder{
		body: body,
		form: multipart.NewWriter(body),
	}
}

// ----------------------------------------------------------------------------

{'fraction_non_alphanumeric': 0.14065866420437056, 'fraction_numerical': 0.0, 'mean_word_length': 2.910950661853189, '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': '3648715', 'n_tokens_mistral': 932, 'n_tokens_neox': 916, 'n_words': 354}