You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@fineract.apache.org by "Awasum Yannick (Jira)" <ji...@apache.org> on 2019/12/22 11:35:00 UTC

[jira] [Closed] (FINERACT-426) Filter to optionally compress response with gzip

     [ https://issues.apache.org/jira/browse/FINERACT-426?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Awasum Yannick closed FINERACT-426.
-----------------------------------
    Fix Version/s: 1.3.0
       Resolution: Fixed

PR merged for this: [https://github.com/apache/fineract/pull/450]

> Filter to optionally compress response with gzip
> ------------------------------------------------
>
>                 Key: FINERACT-426
>                 URL: https://issues.apache.org/jira/browse/FINERACT-426
>             Project: Apache Fineract
>          Issue Type: Improvement
>            Reporter: Avik Ganguly
>            Assignee: Avik Ganguly
>            Priority: Minor
>              Labels: easyfix, gsoc, newbie, p2, performance
>             Fix For: 1.3.0
>
>
> Accept a query parameter like isCompressionRequired. If this query param is present, compress the response using gzip. This will ensure less bandwidth usage if field apps are using mobile data.
> Sample Code for response filter :-
> Inside filter method :-
> if (request.getRequestHeaders().getFirst(HttpHeaders.ACCEPT_ENCODING).contains("gzip")) {
> 	                response.getHttpHeaders().add(HttpHeaders.CONTENT_ENCODING, "gzip");
> 	                response.setContainerResponseWriter(
> 	                        new Adapter(response.getContainerResponseWriter()));
> 	            }
>   private static final class Adapter implements ContainerResponseWriter {
>         private final ContainerResponseWriter crw;
>         private GZIPOutputStream gos;
>         Adapter(ContainerResponseWriter crw) {
>             this.crw = crw;
>         }
>         
>         public OutputStream writeStatusAndHeaders(long contentLength, ContainerResponse response) throws IOException {
>            gos = new GZIPOutputStream(crw.writeStatusAndHeaders(-1, response));
>            return gos;
>         }
>         public void finish() throws IOException {
>             gos.finish();
>             crw.finish();
>         }
>     }
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)