hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yaitskov <...@git.apache.org>
Subject [GitHub] httpcore pull request: HTTPCLIENT-1693 client request trailers
Date Sun, 25 Oct 2015 19:43:56 GMT
GitHub user yaitskov opened a pull request:


    HTTPCLIENT-1693 client request trailers

    This patch implements [HTTP 1.1 trailers](https://tools.ietf.org/html/rfc7230#section-4.1.2)
and allows a   client to send some headers after chunked body.
    For example client use streaming content (proxy) and cannot send data  like hash code
of transferred content in traditional headers.
    I opened [ticket](https://issues.apache.org/jira/browse/HTTPCLIENT-1693).
    Here is an example of usage without httpclient. I encountered problems because httpclient
and httpcore trunks are not compatible. So I found example in httpcore and modified it.
    Also there is a new test case for ChunkeOutputStream.
            HttpProcessor httpproc = HttpProcessorBuilder.create()
                    .add(new RequestContent())
                    .add(new RequestTargetHost())
                    .add(new RequestConnControl())
                    .add(new RequestUserAgent("Test/1.1"))
            HttpRequestExecutor httpexecutor = new HttpRequestExecutor();
            HttpCoreContext coreContext = HttpCoreContext.create();
            HttpHost host = new HttpHost("localhost", 8080);
            DefaultBHttpClientConnection conn = new DefaultBHttpClientConnection(8 * 1024);
            InputStreamEntity requestBody =
                    new InputStreamEntity(
                            new ByteArrayInputStream(
                                    "This is the third test request (will be chunked)"
            Socket socket = new Socket(host.getHostName(), host.getPort());
            BasicHttpRequest request = new BasicHttpRequest("POST", "/");
            Map<String, Callable<String>> m = new HashMap<>();
            m.put("t1", new Callable<String>() {
                public String call() throws Exception {
                    return "Hello world";
            httpexecutor.preProcess(request, httpproc, coreContext);
            HttpResponse response = httpexecutor.execute(request, conn, coreContext);
            httpexecutor.postProcess(response, httpproc, coreContext);
            System.out.println("<< Response: " + response.getStatusLine());

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/yaitskov/httpcore client-request-trailers

Alternatively you can review and apply these changes as the patch at:


To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #14
commit 4c08c2bd19a61a9cbcefd325074d4869a63a9a68
Author: Your Name <you@example.com>
Date:   2015-10-25T19:26:20Z

    client request trailers


If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.

To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org

View raw message