Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix IndexOutOfBounds in apache http clients #4575

Merged
merged 2 commits into from
Nov 3, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ static List<String> headersToList(Header[] headers) {
}
List<String> headersList = new ArrayList<>(headers.length);
for (int i = 0; i < headers.length; ++i) {
headersList.set(i, headers[i].getValue());
headersList.add(headers[i].getValue());
}
return headersList;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ abstract class ApacheHttpAsyncClientTest extends HttpClientTest<HttpUriRequest>
client.start()
}

@Override
String userAgent() {
return "httpasyncclient"
}

@Override
Integer responseCodeOnRedirectError() {
return 302
Expand All @@ -42,6 +47,7 @@ abstract class ApacheHttpAsyncClientTest extends HttpClientTest<HttpUriRequest>
@Override
HttpUriRequest buildRequest(String method, URI uri, Map<String, String> headers) {
def request = createRequest(method, uri)
request.addHeader("user-agent", userAgent())
headers.entrySet().each {
request.setHeader(new BasicHeader(it.key, it.value))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static List<String> headersToList(Header[] headers) {
}
List<String> headersList = new ArrayList<>(headers.length);
for (int i = 0; i < headers.length; ++i) {
headersList.set(i, headers[i].getValue());
headersList.add(headers[i].getValue());
}
return headersList;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,15 @@ abstract class ApacheHttpClientTest<T extends HttpRequest> extends HttpClientTes
client.getConnectionManager().shutdown()
}

@Override
String userAgent() {
return "apachehttpclient"
}

@Override
T buildRequest(String method, URI uri, Map<String, String> headers) {
def request = createRequest(method, uri)
request.addHeader("user-agent", userAgent())
headers.entrySet().each {
request.setHeader(new BasicHeader(it.key, it.value))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static List<String> headersToList(Header[] headers) {
}
List<String> headersList = new ArrayList<>(headers.length);
for (int i = 0; i < headers.length; ++i) {
headersList.set(i, headers[i].getValue());
headersList.add(headers[i].getValue());
}
return headersList;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ abstract class ApacheHttpClientTest<T extends HttpRequest> extends HttpClientTes

abstract protected CloseableHttpClient createClient()

@Override
String userAgent() {
return "apachehttpclient"
}

@Override
Integer responseCodeOnRedirectError() {
return 302
Expand All @@ -35,6 +40,7 @@ abstract class ApacheHttpClientTest<T extends HttpRequest> extends HttpClientTes
@Override
T buildRequest(String method, URI uri, Map<String, String> headers) {
def request = createRequest(method, uri)
request.addHeader("user-agent", userAgent())
headers.entrySet().each {
request.setHeader(new BasicHeader(it.key, it.value))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ private static List<String> headersToList(Header[] headers) {
}
List<String> headersList = new ArrayList<>(headers.length);
for (int i = 0; i < headers.length; ++i) {
headersList.set(i, headers[i].getValue());
headersList.add(headers[i].getValue());
}
return headersList;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,15 @@ abstract class ApacheHttpClientTest<T extends HttpRequest> extends HttpClientTes
client = builder.build()
}

@Override
String userAgent() {
return "apachehttpclient"
}

@Override
T buildRequest(String method, URI uri, Map<String, String> headers) {
def request = createRequest(method, uri)
request.addHeader("user-agent", userAgent())
headers.entrySet().each {
request.setHeader(new BasicHeader(it.key, it.value))
}
Expand Down