<commit_before>// Copyright 2014 <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 buildkite

import (
	"encoding/base64"
	"fmt"
	"net/http"
	"time"
)

// TokenAuthTransport manages injection of the API token for each request
type TokenAuthTransport struct {
	APIToken string
	Debug    bool
}

// RoundTrip invoked each time a request is made
func (t TokenAuthTransport) RoundTrip(req *http.Request) (*http.Response, error) {
	req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", t.APIToken))
	ts := time.Now()
	res, err := http.DefaultTransport.RoundTrip(req)
	if t.Debug {
		fmt.Printf("DEBUG uri = %s time = %s\n", req.URL, time.Now().Sub(ts))
	}
	return res, err
}

// Client builds a new http client.
func (t *TokenAuthTransport) Client() *http.Client {
	return &http.Client{Transport: t}
}

// NewTokenConfig configure authentication using an API token<commit_msg>Tweaked debug output.<commit_after>// Copyright 2014 <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 buildkite

import (
	"encoding/base64"
	"fmt"
	"net/http"
	"time"
)

// TokenAuthTransport manages injection of the API token for each request
type TokenAuthTransport struct {
	APIToken string
	Debug    bool
}

// RoundTrip invoked each time a request is made
func (t TokenAuthTransport) RoundTrip(req *http.Request) (*http.Response, error) {
	req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", t.APIToken))
	ts := time.Now()
	res, err := http.DefaultTransport.RoundTrip(req)
	if t.Debug {
		fmt.Printf("DEBUG uri=%s time=%s\n", req.URL, time.Now().Sub(ts))
	}
	return res, err
}

// Client builds a new http client.
func (t *TokenAuthTransport) Client() *http.Client {
	return &http.Client{Transport: t}
}

// NewTokenConfig configure authentication using an API token
{'fraction_non_alphanumeric': 0.12100926879505665, 'fraction_numerical': 0.006179196704428424, 'mean_word_length': 4.0863874345549736, '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': '3345678', 'n_tokens_mistral': 633, 'n_tokens_neox': 620, 'n_words': 213}