Skip to content

Can I use custom pipeline instead of default  #715

Closed

Description

@rajcspsg

Hi,

This is the question -

The examples for starting the server in this project always using Server.make.
If I want to use some custom http pipeline , How can I achieve the same?

Activity

  1. locked and limited conversation to collaborators on Dec 29, 2021
  2. converted this issue into a discussion #717 on Dec 29, 2021
  3. unlocked this conversation on Dec 29, 2021
  4. rajcspsg commented on Dec 29, 2021

    @rajcspsg
    ContributorAuthor

    Let me add more details to this issue -

    the client can send requests in payload compressed based on the content-encoding header. For example, if the contents are compressed in gzipped format, then the content-encoding header would be gzip. Netty provides HttpContentDecompressor channel handler for this feature.

    Similarly the server can also send response in compressed format based on the Accept-Encoding header in the request. For this Netty provides HttpContentCompressor channelHandler for this feature.

    I've an example here. The code is on github here. you can run the project by using gradle just-netty:runMain to run the server. The example of client to call the server is here

    try(CloseableHttpClient httpclient = HttpClients.createDefault()) {
            HttpPost httppost = new HttpPost("http://localhost:5880/test");
            String payload = "{ \"test\" : 1 }";
            EntityBuilder builder = EntityBuilder.create().gzipCompress().setContentEncoding("gzip").chunked().setText(payload);
            HttpEntity entity = builder.build();
            httppost.setEntity(entity);
            System.out.println();
            httppost.setHeader("Accept-Encoding", "gzip,deflate");
            httppost.setHeader("Content-Encoding", "gzip");
            System.out.println("Executing request: " + httppost.getRequestLine());
            CloseableHttpResponse response = httpclient.execute(httppost);
            try {
                System.out.println("----------------------------------------");
                System.out.println(response.getStatusLine());
                System.out.println(EntityUtils.toString(response.getEntity()));
            } finally {
                response.close();
            }
        }

    In my current organization we use HttpContentCompressor and HttpContentDecompressor in our server and also has some additional handler in pipeline.

    IMHO, zio-http should allow users to provide option for defining custom HttpPipeline. In cases if the users didn't provide additional pipeline , then Server.make should use default pipeline.

    Please let me know if I'm not clear in this problem description.

  5. tusharmath commented on Jan 20, 2022

    @tusharmath
    Collaborator

    This seems like something we should have in ZIO Http.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions