4848import java .io .InputStream ;
4949import java .io .InputStreamReader ;
5050import 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 ;
5255import java .util .regex .Matcher ;
5356import 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 }
0 commit comments