Skip to content

Commit e64d501

Browse files
committed
remove unused header arguments from request methods
1 parent 824dafb commit e64d501

File tree

2 files changed

+18
-20
lines changed

2 files changed

+18
-20
lines changed

src/main/java/com/urswolfer/gerrit/client/rest/http/GerritRestClient.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@
4848
import java.io.InputStream;
4949
import java.io.InputStreamReader;
5050
import java.io.Reader;
51-
import java.util.*;
51+
import java.util.Arrays;
52+
import java.util.Date;
53+
import java.util.List;
54+
import java.util.Set;
5255
import java.util.regex.Matcher;
5356
import java.util.regex.Pattern;
5457

@@ -91,29 +94,29 @@ public Gson getGson() {
9194
return GSON;
9295
}
9396

94-
public JsonElement getRequest(String path, Header... headers) throws RestApiException {
95-
return request(path, null, Arrays.asList(headers), HttpVerb.GET);
97+
public JsonElement getRequest(String path) throws RestApiException {
98+
return request(path, null, HttpVerb.GET);
9699
}
97100

98-
public JsonElement postRequest(String path, String requestBody, Header... headers) throws RestApiException {
99-
return request(path, requestBody, Arrays.asList(headers), HttpVerb.POST);
101+
public JsonElement postRequest(String path, String requestBody) throws RestApiException {
102+
return request(path, requestBody, HttpVerb.POST);
100103
}
101104

102-
public JsonElement putRequest(String path, Header... headers) throws RestApiException {
103-
return putRequest(path, null, headers);
105+
public JsonElement putRequest(String path) throws RestApiException {
106+
return putRequest(path, null);
104107
}
105108

106-
public JsonElement putRequest(String path, String requestBody, Header... headers) throws RestApiException {
107-
return request(path, requestBody, Arrays.asList(headers), HttpVerb.PUT);
109+
public JsonElement putRequest(String path, String requestBody) throws RestApiException {
110+
return request(path, requestBody, HttpVerb.PUT);
108111
}
109112

110-
public JsonElement deleteRequest(String path, Header... headers) throws RestApiException {
111-
return request(path, null, Arrays.asList(headers), HttpVerb.DELETE);
113+
public JsonElement deleteRequest(String path) throws RestApiException {
114+
return request(path, null, HttpVerb.DELETE);
112115
}
113116

114-
public JsonElement request(String path, String requestBody, Collection<Header> headers, HttpVerb verb) throws RestApiException {
117+
public JsonElement request(String path, String requestBody, HttpVerb verb) throws RestApiException {
115118
try {
116-
HttpResponse response = doRest(path, requestBody, headers, verb);
119+
HttpResponse response = doRest(path, requestBody, verb);
117120

118121
checkStatusCode(response);
119122

@@ -132,7 +135,7 @@ public JsonElement request(String path, String requestBody, Collection<Header> h
132135
}
133136
}
134137

135-
public HttpResponse doRest(String path, String requestBody, Collection<Header> headers, HttpVerb verb) throws IOException, RestApiException {
138+
public HttpResponse doRest(String path, String requestBody, HttpVerb verb) throws IOException, RestApiException {
136139
HttpContext httpContext = new BasicHttpContext();
137140
HttpClientBuilder client = getHttpClient(httpContext);
138141

@@ -165,9 +168,6 @@ public HttpResponse doRest(String path, String requestBody, Collection<Header> h
165168
default:
166169
throw new IllegalStateException("Unknown or unsupported HttpVerb method: " + verb.toString());
167170
}
168-
for (Header header : headers) {
169-
method.addHeader(header);
170-
}
171171
if (gerritAuthOptional.isPresent()) {
172172
method.addHeader("X-Gerrit-Auth", gerritAuthOptional.get());
173173
}

src/main/java/com/urswolfer/gerrit/client/rest/http/tools/ToolsRestClient.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,10 @@
1919
import com.google.gerrit.extensions.restapi.RestApiException;
2020
import com.urswolfer.gerrit.client.rest.http.GerritRestClient;
2121
import com.urswolfer.gerrit.client.rest.tools.Tools;
22-
import org.apache.http.Header;
2322
import org.apache.http.HttpResponse;
2423

2524
import java.io.IOException;
2625
import java.io.InputStream;
27-
import java.util.Collections;
2826

2927
/**
3028
* @author Urs Wolfer
@@ -40,7 +38,7 @@ public ToolsRestClient(GerritRestClient gerritRestClient) {
4038
@Override
4139
public InputStream getCommitMessageHook() throws RestApiException {
4240
try {
43-
HttpResponse response = gerritRestClient.doRest("/tools/hooks/commit-msg", null, Collections.<Header>emptyList(), GerritRestClient.HttpVerb.GET);
41+
HttpResponse response = gerritRestClient.doRest("/tools/hooks/commit-msg", null, GerritRestClient.HttpVerb.GET);
4442
int statusCode = response.getStatusLine().getStatusCode();
4543
if (statusCode >= 200 && statusCode < 400) {
4644
return response.getEntity().getContent();

0 commit comments

Comments
 (0)