Skip to content

Commit

Permalink
Merge pull request #42 from JoeHitHard/master
Browse files Browse the repository at this point in the history
add req headers to send req
  • Loading branch information
JoeHitHard authored Oct 26, 2022
2 parents d3e42d6 + 84a2fb6 commit 7eefd21
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@
import java.net.URL;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.zip.GZIPOutputStream;
Expand Down Expand Up @@ -96,6 +93,9 @@ public void send(Collection<DataPoint> dataPoints) throws ConnectException, Resp
}

public void send(Collection<DataPoint> dataPoints, Sanitizer sanitizer) throws ConnectException, ResponseStatusException, IOException {
send(dataPoints, sanitizer, null);
}
public void send(Collection<DataPoint> dataPoints, Sanitizer sanitizer, Map<String, String> reqHeaders) throws ConnectException, ResponseStatusException, IOException {


if (dataPoints.isEmpty()) {
Expand All @@ -118,6 +118,9 @@ public void send(Collection<DataPoint> dataPoints, Sanitizer sanitizer) throws C
urlConnection.setRequestProperty(CONTENT_ENCODING, CONTENT_ENCODING_GZIP);
}
urlConnection.setRequestProperty("Authorization", generateAuthHeader());
if (reqHeaders != null && !reqHeaders.isEmpty()) {
reqHeaders.forEach(urlConnection::setRequestProperty);
}
urlConnection.setRequestMethod("POST");
urlConnection.setDoInput(true);
urlConnection.setDoOutput(true);
Expand Down

0 comments on commit 7eefd21

Please sign in to comment.