users@grizzly.java.net

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

From: testn <test1_at_doramail.com>
Date: Thu, 28 May 2015 23:45:05 -0700 (MST)

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();
    }
}




--
View this message in context: http://grizzly.1045725.n5.nabble.com/HTTP-Response-Header-seems-to-be-missing-in-AHC-1-9-tp5710850p5710865.html
Sent from the Grizzly - Users mailing list archive at Nabble.com.