You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@fineract.apache.org by "Michael Vorburger (Jira)" <ji...@apache.org> on 2020/08/24 07:50:00 UTC
[jira] [Commented] (FINERACT-426) Filter to optionally compress
response with gzip
[ https://issues.apache.org/jira/browse/FINERACT-426?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17183024#comment-17183024 ]
Michael Vorburger commented on FINERACT-426:
--------------------------------------------
Note for posterity: The PR #450 (above) went into 1.3.0, but that apparently then (I only vaguely remember from past discussions) caused _"has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource."_. I got reminded of this in today's dev@ list thread subject _"Error which installing Self-service WebApp"_, so it's probably worth to clarify:
This feature (PR #450) was actually reverted in https://github.com/apache/fineract/commit/04494a4e434bbbc377858801c00c160c5f899640 for FINERACT-755, due to that CORS problem this apparently caused. The revert was intended for a 1.3.1 but that was never released - or not yet, see FINERACT-877. Our 1.3.0 release is effectively broken, due to this. Let's discuss what to do about that further in FINERACT-877.
[~kumaranath_fernando] and [~avikg] ([~avikganguly010] ?) if you still think this feature (to compress HTTP responses) would be useful, you could re-open this issue, change the Fix Version (probably to 1.5.0, at this point) and propose a new PR.. making sure you fix the CORS problem (and perhaps ideally with an IT?). But if you / anyone wants to do that, IMHO it would be best not to build on the original PR, but instead just use Spring's (now) built-in response compression, see https://docs.spring.io/spring-boot/docs/2.3.3.RELEASE/reference/html/appendix-application-properties.html#server-properties.
> 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)