<commit_before>package ch.rmy.android.http_shortcuts.http;

import java.util.HashMap;
import java.util.Map;

import android.util.Base64;

import com.android.volley.AuthFailureError;
import com.android.volley.Response.ErrorListener;
import com.android.volley.Response.Listener;
import com.android.volley.toolbox.StringRequest;

public class AuthRequest extends StringRequest {

	private final String username;
	private final String password;
	private final String bodyContent;
	private final Map<String, String> parameters;
	private final Map<String, String> headers;

	public AuthRequest(int method, String url, String username, String password, String bodyContent, Listener<String> listener, ErrorListener errorListener) {
		super(method, url, listener, errorListener);

		this.username = username;
		this.password = password;
		this.bodyContent = bodyContent;

		parameters = new HashMap<String, String>();
		headers = new HashMap<String, String>();
	}

	@Override
	public byte[] getBody() throws AuthFailureError {
		if (bodyContent.isEmpty()) {
			return super.getBody();
		} else {
			return bodyContent.getBytes();
		}
	}

	@Override
	public Map<String, String> getHeaders() throws AuthFailureError {
		headers.putAll(super.getHeaders());

		headers.put("Connection", "close");

		if (!username.isEmpty() || !password.isEmpty()) {
			String creds = String.format("%s:%s", username, password);
			String auth = "Basic " + Base64.encodeToString(creds.getBytes(), Base64.DEFAULT);
			headers.put("Authorization", auth);
		}
		return headers;
	}

	@Override
	public Map<String, String> getParams() {
		return parameters;
	}

	public void addParameter(String key, String value) {
		parameters.put(key, value);
	}

	public void addHeader(String key, String value) {
		headers.put(key, value);
	}

}
<commit_msg>Bugfix: Authorization no longer breaks HTTP request headers<commit_after>package ch.rmy.android.http_shortcuts.http;

import java.util.HashMap;
import java.util.Map;

import android.util.Base64;

import com.android.volley.AuthFailureError;
import com.android.volley.Response.ErrorListener;
import com.android.volley.Response.Listener;
import com.android.volley.toolbox.StringRequest;

public class AuthRequest extends StringRequest {

	private final String username;
	private final String password;
	private final String bodyContent;
	private final Map<String, String> parameters;
	private final Map<String, String> headers;

	public AuthRequest(int method, String url, String username, String password, String bodyContent, Listener<String> listener, ErrorListener errorListener) {
		super(method, url, listener, errorListener);

		this.username = username;
		this.password = password;
		this.bodyContent = bodyContent;

		parameters = new HashMap<String, String>();
		headers = new HashMap<String, String>();
	}

	@Override
	public byte[] getBody() throws AuthFailureError {
		if (bodyContent.isEmpty()) {
			return super.getBody();
		} else {
			return bodyContent.getBytes();
		}
	}

	@Override
	public Map<String, String> getHeaders() throws AuthFailureError {
		headers.putAll(super.getHeaders());

		headers.put("Connection", "close");

		if (!username.isEmpty() || !password.isEmpty()) {
			String creds = String.format("%s:%s", username, password);
			String auth = "Basic " + Base64.encodeToString(creds.getBytes(), Base64.NO_WRAP);
			headers.put("Authorization", auth);
		}

		return headers;
	}

	@Override
	public Map<String, String> getParams() {
		return parameters;
	}

	public void addParameter(String key, String value) {
		parameters.put(key, value);
	}

	public void addHeader(String key, String value) {
		headers.put(key, value);
	}

}

{'fraction_non_alphanumeric': 0.11271676300578035, 'fraction_numerical': 0.0031529164477141357, 'mean_word_length': 4.144594594594595, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '6988322', 'n_tokens_mistral': 1189, 'n_tokens_neox': 1072, 'n_words': 285}