You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@knox.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2021/06/18 21:06:00 UTC

[jira] [Work logged] (KNOX-2622) Support Deflate Encoding for the Inbound Response

     [ https://issues.apache.org/jira/browse/KNOX-2622?focusedWorklogId=611984&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-611984 ]

ASF GitHub Bot logged work on KNOX-2622:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 18/Jun/21 21:05
            Start Date: 18/Jun/21 21:05
    Worklog Time Spent: 10m 
      Work Description: xuzikun2003 commented on pull request #459:
URL: https://github.com/apache/knox/pull/459#issuecomment-864207198


   @lmccay , the style issue is already fixed.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Issue Time Tracking
-------------------

            Worklog Id:     (was: 611984)
    Remaining Estimate: 0h
            Time Spent: 10m

> Support Deflate Encoding for the Inbound Response
> -------------------------------------------------
>
>                 Key: KNOX-2622
>                 URL: https://issues.apache.org/jira/browse/KNOX-2622
>             Project: Apache Knox
>          Issue Type: Improvement
>          Components: Server
>    Affects Versions: 1.4.0
>            Reporter: Zikun
>            Priority: Major
>             Fix For: 1.5.0
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> Currently, Knox only supports the Content-Encoding "gzip" and the Content-Encoding "deflate" is not supported. When the upstream server (such as Livy 0.7 Server) returns a response which is deflated, Knox does not know how to decode it.
>  
> This is the part of logic that needs to be improved.
>   
>      final InputStream inStream;
>     final OutputStream outStream;
>     if( filter != null ) 
>     \{       // Use this way to check whether the input stream is gzip compressed, in case       // the content encoding header is unknown, as it could be unset in inbound response       boolean isGzip = false;       final BufferedInputStream inBuffer = new BufferedInputStream(input, STREAM_BUFFER_SIZE);       inBuffer.mark(2);       byte [] signature = new byte[2];       int len = inBuffer.read(signature);       if( len == 2 && signature[ 0 ] == (byte) 0x1f && signature[ 1 ] == (byte) 0x8b )        \{         isGzip = true;       }
>       inBuffer.reset();
>       final InputStream unFilteredStream;
>       if(isGzip) 
>       \{         unFilteredStream = new GzipCompressorInputStream(inBuffer, true);       }
>        else 
>       \{         unFilteredStream = inBuffer;       }
>       String charset = MimeTypes.getCharset( mimeType, StandardCharsets.UTF_8.name() );
>       inStream = filter.filter( unFilteredStream, charset, rewriter, this, UrlRewriter.Direction.OUT, filterContentConfig );
>       outStream = (isGzip) ? new GZIPOutputStream(output, STREAM_BUFFER_SIZE) : output;
>     } else 
>     \{       inStream = input;       outStream = output;     }
>  
> The above code only considers the "gzip" format and the "deflate" format is not considered. We should also handle the case when the format is "deflate" and use InflaterInputStream to read the in-bound response and use DeflaterOutputStream to write the out-bound response.



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