https://issues.apache.org/bugzilla/show_bug.cgi?id=56663

Long Zou <long...@hotmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|WORKSFORME                  |---

--- Comment #4 from Long Zou <long...@hotmail.com> ---
1. I test tomcat 8.0.5 and 8.0.8.
2. Connector is using NIO.
3. I understood the routines. 

Enclosing my code as below:

    final class SyncServiceReadListener implements ReadListener {
        private final AsyncContext _asyncCtx;
        private final ServletInputStream _input;
        private final HttpServletResponse _response;
        private final Locale _locale;
        private final ByteArrayOutputStream _bufferStream = new
ByteArrayOutputStream();
        SyncServiceReadListener(ServletInputStream input, HttpServletResponse
res,  AsyncContext ctx, Locale locale){
            _input = input;
            _asyncCtx = ctx;
            _response = res;
            _locale = locale;
            _serviceResponse = serviceResponse;
        }

        public void onDataAvailable() throws IOException {
            byte[] buf = new byte[1024];
            int len = 0;
            try{
                while ( _input.isReady() && (len = _input.read(buf)) != -1) {
                    _bufferStream.write(buf, 0, len);
                }
            }catch(Exception ex){
                logger.debug(ex.getMessage());
            }
        }

        public void onAllDataRead() throws IOException {
            try{
                _bufferStream.flush();
                _bufferStream.close();
            }catch(Exception ex){
                logger.debug(ex.getMessage());
            }

            ///By here, the _bufferStream.toByteArray() just returned 1024
bytes. 
            ...
        }

        public void onError(Throwable thrwbl) {
            if( thrwbl != null )
                logger.error(thrwbl.getMessage(), thrwbl);
            _asyncCtx.complete();
        }
    }

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to