HTTP Response Header seems to be missing in AHC 1.9

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

HTTP Response Header seems to be missing in AHC 1.9

testn
I just checked out AHC 1.9/Grizzly 2.3.21 and tried it with my code. It seems to work ok but when I checked the http response header, it seems to be missing. Was there a regression between 1.8 and 1.9? I traced down the code and it looks like Grizzly does not call AsyncHandler.onHeadersReceived in 1.9
Reply | Threaded
Open this post in threaded view
|

Re: HTTP Response Header seems to be missing in AHC 1.9

oleksiys
Administrator
Please file an issue and attach a testcase.

Thank you!

WBR,
Alexey.

On 27.05.15 07:44, testn wrote:

> I just checked out AHC 1.9/Grizzly 2.3.21 and tried it with my code. It seems
> to work ok but when I checked the http response header, it seems to be
> missing. Was there a regression between 1.8 and 1.9? I traced down the code
> and it looks like Grizzly does not call AsyncHandler.onHeadersReceived in
> 1.9
>
>
>
> --
> View this message in context: http://grizzly.1045725.n5.nabble.com/HTTP-Response-Header-seems-to-be-missing-in-AHC-1-9-tp5710850.html
> Sent from the Grizzly - Users mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

Re: HTTP Response Header seems to be missing in AHC 1.9

testn
I don't have access to Jira at the moment. Here is the simple case. I uploaded the data to Swift and expected to get Etag back. I checked in the proxy and it seems to return Etag data but the header is not available from Response.getHeader

import com.ning.http.client.*;
import com.ning.http.client.providers.grizzly.FeedableBodyGenerator;
import com.ning.http.client.providers.grizzly.GrizzlyAsyncHttpProvider;
import com.ning.http.client.providers.grizzly.GrizzlyAsyncHttpProviderConfig;
import com.ning.http.client.providers.grizzly.TransportCustomizer;
import org.glassfish.grizzly.filterchain.FilterChainBuilder;
import org.glassfish.grizzly.memory.Buffers;
import org.glassfish.grizzly.memory.MemoryManager;
import org.glassfish.grizzly.nio.transport.TCPNIOTransport;

import java.io.FileInputStream;
import java.io.IOException;

public class Main {
    public static void main(String[] args) throws Exception {
        final int chunkSize = 8192;
        GrizzlyAsyncHttpProviderConfig httpConfig = new GrizzlyAsyncHttpProviderConfig();
        httpConfig.addProperty(GrizzlyAsyncHttpProviderConfig.Property.TRANSPORT_CUSTOMIZER, new TransportCustomizer() {
            public void customize(TCPNIOTransport tcpnioTransport, FilterChainBuilder filterChainBuilder) {
                tcpnioTransport.setOptimizedForMultiplexing(true);
                tcpnioTransport.getAsyncQueueIO().getWriter().setMaxPendingBytesPerConnection(8192);
            }
        });
        AsyncHttpClientConfig.Builder builder = new AsyncHttpClientConfig.Builder();
        builder.setIOThreadMultiplier(1);
        builder.setProxyServer(new ProxyServer("127.0.0.1", 8080));
        builder.setAsyncHttpClientProviderConfig(httpConfig);
        AsyncHttpClientConfig config = builder.build();
        GrizzlyAsyncHttpProvider provider = new GrizzlyAsyncHttpProvider(config);
        AsyncHttpClient client = new AsyncHttpClient(provider);
        AsyncHttpClient.BoundRequestBuilder requestBuilder = client.preparePut("http://192.168.8.80:8080/v1/AUTH_test/test/test2");

        final FeedableBodyGenerator bodyGenerator = new FeedableBodyGenerator();
        bodyGenerator.setMaxPendingBytes(chunkSize);
        final FeedableBodyGenerator.Feeder feeder = new FeedableBodyGenerator.SimpleFeeder(bodyGenerator) {
            @Override
            public void flush() throws IOException {
                try (FileInputStream s = new FileInputStream("/tmp/perf.201505.log")) {
                    byte[] buf = new byte[chunkSize];
                    int byteRead;
                    while ((byteRead = s.read(buf)) >= 0) {
                        feed(Buffers.wrap(MemoryManager.DEFAULT_MEMORY_MANAGER, buf, 0, byteRead), false);
                    }
                    feed(Buffers.wrap(MemoryManager.DEFAULT_MEMORY_MANAGER, buf, 0, 0), true);
                }
            }
        };
        bodyGenerator.setFeeder(feeder);
        requestBuilder.setBody(bodyGenerator);
        requestBuilder.addHeader("x-auth-token", "AUTH_tk4b53d56f40cc4315b9aaceea4cf472a1");
        Request request = requestBuilder.build();
        ListenableFuture<Response> future = client.executeRequest(request);
        Response response = future.get();
        System.out.println(response.getHeader("Etag"));
        client.close();
    }
}
Reply | Threaded
Open this post in threaded view
|

Re: HTTP Response Header seems to be missing in AHC 1.9

testn
I just retested it again. It seems to work now. I guess I must have a corrupted jar in there. Sorry for confusion.