Extend control over HttpUtils.Request headers
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
b92f9c3d4f
commit
d388ca8052
@ -68,9 +68,9 @@ public class HttpUtils {
|
|||||||
public Request(Method method, String url) throws URISyntaxException {
|
public Request(Method method, String url) throws URISyntaxException {
|
||||||
this.url = url.replace(" ", "%20");
|
this.url = url.replace(" ", "%20");
|
||||||
this.builder = HttpRequest.newBuilder()
|
this.builder = HttpRequest.newBuilder()
|
||||||
.uri(new URI(this.url))
|
.uri(new URI(this.url));
|
||||||
.header("User-Agent", userAgent);
|
|
||||||
this.method = method;
|
this.method = method;
|
||||||
|
userAgent(userAgent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Request bearer(String token) {
|
public Request bearer(String token) {
|
||||||
@ -84,6 +84,15 @@ public class HttpUtils {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Request setHeader(String name, String value) {
|
||||||
|
builder.setHeader(name, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Request userAgent(String value) {
|
||||||
|
return setHeader("User-Agent", value);
|
||||||
|
}
|
||||||
|
|
||||||
public Request bodyString(String string) {
|
public Request bodyString(String string) {
|
||||||
builder.header("Content-Type", "text/plain");
|
builder.header("Content-Type", "text/plain");
|
||||||
builder.method(method.name(), HttpRequest.BodyPublishers.ofString(string));
|
builder.method(method.name(), HttpRequest.BodyPublishers.ofString(string));
|
||||||
|
Loading…
Reference in New Issue
Block a user