Skip to content

Commit 8105e0f

Browse files
committed
Commit fix for AsyncHttpClient#165 from bric3.
1 parent c322357 commit 8105e0f

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

providers/grizzly/src/main/java/com/ning/http/client/providers/grizzly/GrizzlyAsyncHttpProvider.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@
135135
import java.util.concurrent.atomic.AtomicInteger;
136136
import java.util.concurrent.atomic.AtomicLong;
137137

138+
import static com.ning.http.client.providers.grizzly.GrizzlyAsyncHttpProviderConfig.Property.MAX_HTTP_PACKET_HEADER_SIZE;
138139
import static com.ning.http.client.providers.grizzly.GrizzlyAsyncHttpProviderConfig.Property.TRANSPORT_CUSTOMIZER;
139140

140141
/**
@@ -370,8 +371,14 @@ public void onTimeout(Connection connection) {
370371
false);
371372
final SwitchingSSLFilter filter = new SwitchingSSLFilter(configurator, defaultSecState);
372373
fcb.add(filter);
373-
final AsyncHttpClientEventFilter eventFilter = new
374-
AsyncHttpClientEventFilter(this);
374+
GrizzlyAsyncHttpProviderConfig providerConfig =
375+
(GrizzlyAsyncHttpProviderConfig) clientConfig.getAsyncHttpProviderConfig();
376+
final AsyncHttpClientEventFilter eventFilter;
377+
if (providerConfig != null) {
378+
eventFilter = new AsyncHttpClientEventFilter(this, (Integer) providerConfig.getProperty(MAX_HTTP_PACKET_HEADER_SIZE));
379+
} else {
380+
eventFilter = new AsyncHttpClientEventFilter(this);
381+
}
375382
final AsyncHttpClientFilter clientFilter =
376383
new AsyncHttpClientFilter(clientConfig);
377384
ContentEncoding[] encodings = eventFilter.getContentEncodings();
@@ -389,8 +396,6 @@ public void onTimeout(Connection connection) {
389396
fcb.add(eventFilter);
390397
fcb.add(clientFilter);
391398

392-
GrizzlyAsyncHttpProviderConfig providerConfig =
393-
(GrizzlyAsyncHttpProviderConfig) clientConfig.getAsyncHttpProviderConfig();
394399
if (providerConfig != null) {
395400
final TransportCustomizer customizer = (TransportCustomizer)
396401
providerConfig.getProperty(TRANSPORT_CUSTOMIZER);
@@ -1070,7 +1075,14 @@ private static final class AsyncHttpClientEventFilter extends HttpClientFilter {
10701075

10711076

10721077
AsyncHttpClientEventFilter(final GrizzlyAsyncHttpProvider provider) {
1078+
this(provider, DEFAULT_MAX_HTTP_PACKET_HEADER_SIZE);
1079+
}
1080+
1081+
1082+
AsyncHttpClientEventFilter(final GrizzlyAsyncHttpProvider provider,
1083+
final int maxHeaderSize) {
10731084

1085+
super(maxHeaderSize);
10741086
this.provider = provider;
10751087
HANDLER_MAP.put(HttpStatus.UNAUTHORIZED_401.getStatusCode(),
10761088
AuthorizationHandler.INSTANCE);

providers/grizzly/src/main/java/com/ning/http/client/providers/grizzly/GrizzlyAsyncHttpProviderConfig.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
package com.ning.http.client.providers.grizzly;
1515

1616
import com.ning.http.client.AsyncHttpProviderConfig;
17+
import org.glassfish.grizzly.http.HttpCodecFilter;
1718
import org.glassfish.grizzly.nio.transport.TCPNIOTransport;
1819

1920
import java.util.HashMap;
@@ -49,7 +50,14 @@ public static enum Property {
4950
*
5051
* @see TransportCustomizer
5152
*/
52-
TRANSPORT_CUSTOMIZER(TransportCustomizer.class);
53+
TRANSPORT_CUSTOMIZER(TransportCustomizer.class),
54+
55+
/**
56+
* Defines the maximum HTTP packet header size.
57+
*
58+
* @since 1.8
59+
*/
60+
MAX_HTTP_PACKET_HEADER_SIZE(Integer.class, HttpCodecFilter.DEFAULT_MAX_HTTP_PACKET_HEADER_SIZE);
5361

5462

5563
final Object defaultValue;
@@ -81,6 +89,7 @@ boolean hasDefaultValue() {
8189
* @throws IllegalArgumentException if the type of the specified value
8290
* does not match the expected type of the specified {@link Property}.
8391
*/
92+
@SuppressWarnings("unchecked")
8493
@Override
8594
public AsyncHttpProviderConfig addProperty(Property name, Object value) {
8695
if (name == null) {

0 commit comments

Comments
 (0)