Thread: [Simpleweb-Support] HTTP Compression
Brought to you by:
niallg
From: Brian D. <wic...@gm...> - 2005-12-13 15:19:58
|
Is there any plans to support gzip or deflate.. or is it there and I am not finding it.. also.. if not why? and.. if not.. any recommends on where to add it.. thanks! Brian |
From: Christophe R. <cr...@ac...> - 2005-12-13 18:14:51
|
I have done this with a custom ProtocolHandler: public class ServerHandler implements ProtocolHandler { private ProtocolHandler _handler; private static final Logger _logger =3D Logger.getLogger(ServerHandler.class); =20 // =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D // Constructor // =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D public ServerHandler(ProtocolHandler handler) { _handler =3D handler; } // =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D // Public methods // =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D public void handle(Request req, Response resp) { resp.set("Server", "Simple"); resp.setDate("Date", System.currentTimeMillis()); // check for compressed request String contentEncoding =3D req.getValue("Content-Encoding"); if ((contentEncoding !=3D null) && (contentEncoding.toLowerCase().indexOf("gzip") > -1)) { _logger.debug("Request is zipped."); req =3D new GZipRequest(req, SimpleWeb.BUFFER_SIZE); } // does the client accept compressed response? String acceptEncoding =3D req.getValue("Accept-Encoding"); if ((!"GET".equals(req.getMethod())) && (acceptEncoding !=3D null) && (acceptEncoding.toLowerCase().indexOf("gzip") > -1)) { _logger.debug("Response will be zipped."); resp =3D new GZipResponse(resp); } /* * Hand the request over to the real server so that targeted service = can be * executed. */ _handler.handle(req, resp); } } -------------------- And the GZipRequest and GZipResponse are mainly a wrapper on a request = where stream getter methods return a GZIP stream: public class GZipRequest implements Request { //extends FilterRequest { private int _size; private Request _req; =20 // =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D // Constructor // =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 /** * Wraps the specified request stream into a GZipStream. */ public GZipRequest(Request request, int size) { //super(request); _req =3D request; if (size <=3D0) { _size =3D 2048; } else { _size =3D size; } } // =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D // Public methods // =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 /** * Returns a GZIPInputStream. */ public InputStream getInputStream() throws IOException { return new GZIPInputStream(_req.getInputStream(), _size); } =20 /** * This can be used to get the URI specified for this HTTP * request. This corresponds to the /index part of a=20 * http://www.domain.com/index URL but may contain the full * URL. This can be set using <code>setURI</code>. * * @return the URI that this HTTP request is targeting */=20 public String getURI(){ return _req.getURI(); } /** * This can be used to set the URI for this HTTP request. * The <code>getURI</code> will return the String entered * which can be a full HTTP URL or a relative path URL. * * @param uri the URI that this HTTP request is to use */ =20 public void setURI(String uri){ _req.setURI(uri); } /** * This can be used to get the HTTP method for this * request. The HTTP specification RFC 2616 specifies the * HTTP request methods in section 9, Method Definitions. * * @return the request method for this request */=20 public String getMethod(){ return _req.getMethod(); } ... ------------------ public class GZipResponse implements Response { //extends FilterResponse = { private Response _resp; =20 // =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D // Constructors // =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D /** * Creates a GZipResponse for the specified Response. */ public GZipResponse(Response response) { //super(response); _resp =3D response; _resp.set("Content-Encoding", "gzip"); } // =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D // Public methods // =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D /** * Returns a GZIPOutputStream. * @see simple.http.Response#getOutputStream() */ public OutputStream getOutputStream() throws IOException { return new GZIPOutputStream(_resp.getOutputStream()); } /** * Returns a GZIPOutputStream. * @see simple.http.Response#getOutputStream(int) */ public OutputStream getOutputStream(int size) throws IOException { return new GZIPOutputStream(_resp.getOutputStream(size), size); } /** * Returns a GZIPOutputStream wrapped into a PrintStream. * @see simple.http.Response#getPrintStream() */ public PrintStream getPrintStream() throws IOException { return getPrintStream(); } /** * Returns a GZIPOutputStream wrapped into a PrintStream. * @see simple.http.Response#getPrintStream(int) */ public PrintStream getPrintStream(int size) throws IOException { return new PrintStream(getOutputStream(size), false); } /** * This represents the status code of the HTTP response. The HTTP * response code represents the type of message that is being sent * to the client. For a description of the codes see RFC 2616=20 * section 10, Status Code Definitions.=20 * * @return the status code that this HTTP response has */=20 public int getCode(){ return _resp.getCode(); } =20 /** * This method allows the status for the response to be changed.=20 * This must be reflected the the response content given to the=20 * client. For a description of the codes see RFC 2616 section=20 * 10, Status Code Definitions. * * @param code the new status code for the HTTP response */=20 public void setCode(int code){ _resp.setCode(code); } .... Christophe > -----Original Message----- > From: sim...@li... [mailto:simpleweb- > sup...@li...] On Behalf Of Brian Davis > Sent: Tuesday, December 13, 2005 10:20 AM > To: sim...@li... > Subject: [Simpleweb-Support] HTTP Compression >=20 > Is there any plans to support gzip or deflate.. or is it there and I > am not finding it.. also.. if not why? and.. if not.. any recommends > on where to add it.. >=20 > thanks! >=20 > Brian >=20 >=20 > ------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. Do you grep through log > files > for problems? Stop! Download the new AJAX search engine that makes > searching your log files as easy as surfing the web. DOWNLOAD = SPLUNK! > http://ads.osdn.com/?ad_idv37&alloc_id=16865&op=3Dick > _______________________________________________ > Simpleweb-Support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simpleweb-support |
From: Brian D. <wic...@gm...> - 2005-12-13 20:21:26
|
Hey cool.. I will look at this in a day or two and let you know how it goes.. did you guys do anything with deflate or just gzip? /Brian On 12/13/05, Christophe Roudet <cr...@ac...> wrote: > I have done this with a custom ProtocolHandler: > > public class ServerHandler implements ProtocolHandler { > private ProtocolHandler _handler; > private static final Logger _logger =3D > Logger.getLogger(ServerHandler.class); > > // =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > // Constructor > // =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > public ServerHandler(ProtocolHandler handler) { > _handler =3D handler; > } > > // =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > // Public methods > // =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > public void handle(Request req, Response resp) { > resp.set("Server", "Simple"); > resp.setDate("Date", System.currentTimeMillis()); > // check for compressed request > String contentEncoding =3D req.getValue("Content-Encoding"); > if ((contentEncoding !=3D null) > && (contentEncoding.toLowerCase().indexOf("gzip") > -1)) { > _logger.debug("Request is zipped."); > req =3D new GZipRequest(req, SimpleWeb.BUFFER_SIZE); > } > // does the client accept compressed response? > String acceptEncoding =3D req.getValue("Accept-Encoding"); > if ((!"GET".equals(req.getMethod())) && (acceptEncoding !=3D null) > && (acceptEncoding.toLowerCase().indexOf("gzip") > -1)) { > _logger.debug("Response will be zipped."); > resp =3D new GZipResponse(resp); > } > /* > * Hand the request over to the real server so that targeted service = can > be > * executed. > */ > _handler.handle(req, resp); > } > } > > -------------------- > And the GZipRequest and GZipResponse are mainly a wrapper on a request wh= ere > stream getter methods return a GZIP stream: > > > public class GZipRequest implements Request { //extends FilterRequest { > private int _size; > private Request _req; > > // =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > // Constructor > // =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > /** > * Wraps the specified request stream into a GZipStream. > */ > public GZipRequest(Request request, int size) { > //super(request); > _req =3D request; > if (size <=3D0) { > _size =3D 2048; > } else { > _size =3D size; > } > } > > // =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > // Public methods > // =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > /** > * Returns a GZIPInputStream. > */ > public InputStream getInputStream() throws IOException { > return new GZIPInputStream(_req.getInputStream(), _size); > } > > /** > * This can be used to get the URI specified for this HTTP > * request. This corresponds to the /index part of a > * http://www.domain.com/index URL but may contain the full > * URL. This can be set using <code>setURI</code>. > * > * @return the URI that this HTTP request is targeting > */ > public String getURI(){ > return _req.getURI(); > } > > /** > * This can be used to set the URI for this HTTP request. > * The <code>getURI</code> will return the String entered > * which can be a full HTTP URL or a relative path URL. > * > * @param uri the URI that this HTTP request is to use > */ > public void setURI(String uri){ > _req.setURI(uri); > } > > /** > * This can be used to get the HTTP method for this > * request. The HTTP specification RFC 2616 specifies the > * HTTP request methods in section 9, Method Definitions. > * > * @return the request method for this request > */ > public String getMethod(){ > return _req.getMethod(); > } > > ... > > ------------------ > > public class GZipResponse implements Response { //extends FilterResponse = { > private Response _resp; > > // =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > // Constructors > // =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > /** > * Creates a GZipResponse for the specified Response. > */ > public GZipResponse(Response response) { > //super(response); > _resp =3D response; > _resp.set("Content-Encoding", "gzip"); > } > > // =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > // Public methods > // =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > /** > * Returns a GZIPOutputStream. > * @see simple.http.Response#getOutputStream() > */ > public OutputStream getOutputStream() throws IOException { > return new GZIPOutputStream(_resp.getOutputStream()); > } > > /** > * Returns a GZIPOutputStream. > * @see simple.http.Response#getOutputStream(int) > */ > public OutputStream getOutputStream(int size) throws IOException { > return new GZIPOutputStream(_resp.getOutputStream(size), size); > } > > /** > * Returns a GZIPOutputStream wrapped into a PrintStream. > * @see simple.http.Response#getPrintStream() > */ > public PrintStream getPrintStream() throws IOException { > return getPrintStream(); > } > > /** > * Returns a GZIPOutputStream wrapped into a PrintStream. > * @see simple.http.Response#getPrintStream(int) > */ > public PrintStream getPrintStream(int size) throws IOException { > return new PrintStream(getOutputStream(size), false); > } > > /** > * This represents the status code of the HTTP response. The HTTP > * response code represents the type of message that is being sent > * to the client. For a description of the codes see RFC 2616 > * section 10, Status Code Definitions. > * > * @return the status code that this HTTP response has > */ > public int getCode(){ > return _resp.getCode(); > } > > /** > * This method allows the status for the response to be changed. > * This must be reflected the the response content given to the > * client. For a description of the codes see RFC 2616 section > * 10, Status Code Definitions. > * > * @param code the new status code for the HTTP response > */ > public void setCode(int code){ > _resp.setCode(code); > } > > .... > > Christophe > > -----Original Message----- > > From: sim...@li... [mailto:simpleweb- > > sup...@li...] On Behalf Of Brian Davis > > Sent: Tuesday, December 13, 2005 10:20 AM > > To: sim...@li... > > Subject: [Simpleweb-Support] HTTP Compression > > > > Is there any plans to support gzip or deflate.. or is it there and I > > am not finding it.. also.. if not why? and.. if not.. any recommends > > on where to add it.. > > > > thanks! > > > > Brian > > > > > > ------------------------------------------------------- > > This SF.net email is sponsored by: Splunk Inc. Do you grep through log > > files > > for problems? Stop! Download the new AJAX search engine that makes > > searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! > > http://ads.osdn.com/?ad_idv37&alloc_id=16865&op=3Dick > > _______________________________________________ > > Simpleweb-Support mailing list > > Sim...@li... > > https://lists.sourceforge.net/lists/listinfo/simpleweb-support > > > > > > ------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. Do you grep through log fi= les > for problems? Stop! Download the new AJAX search engine that makes > searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! > http://ads.osdn.com/?ad_idv37&alloc_id=16865&opclick > _______________________________________________ > Simpleweb-Support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simpleweb-support > |
From: Brian D. <wic...@gm...> - 2005-12-14 19:51:27
|
Hmm... can't seem to get this to work.. also a couple things bother me... first.. in order to do it this way I won't be able to set the content-length because whatever i set would be wrong.. also.. compression should be handled at the framework level if possible.. so.. I was really just wondering why it wasn't supported... out of the box per-se anyway.. thanks for the help! /Brian On 12/13/05, Brian Davis <wic...@gm...> wrote: > Hey cool.. I will look at this in a day or two and let you know how it > goes.. did you guys do anything with deflate or just gzip? > > /Brian > > > On 12/13/05, Christophe Roudet <cr...@ac...> wrote: > > I have done this with a custom ProtocolHandler: > > > > public class ServerHandler implements ProtocolHandler { > > private ProtocolHandler _handler; > > private static final Logger _logger =3D > > Logger.getLogger(ServerHandler.class); > > > > // =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > // Constructor > > // =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > > > public ServerHandler(ProtocolHandler handler) { > > _handler =3D handler; > > } > > > > // =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > // Public methods > > // =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > > > public void handle(Request req, Response resp) { > > resp.set("Server", "Simple"); > > resp.setDate("Date", System.currentTimeMillis()); > > // check for compressed request > > String contentEncoding =3D req.getValue("Content-Encoding"); > > if ((contentEncoding !=3D null) > > && (contentEncoding.toLowerCase().indexOf("gzip") > -1)) { > > _logger.debug("Request is zipped."); > > req =3D new GZipRequest(req, SimpleWeb.BUFFER_SIZE); > > } > > // does the client accept compressed response? > > String acceptEncoding =3D req.getValue("Accept-Encoding"); > > if ((!"GET".equals(req.getMethod())) && (acceptEncoding !=3D null) > > && (acceptEncoding.toLowerCase().indexOf("gzip") > -1)) { > > _logger.debug("Response will be zipped."); > > resp =3D new GZipResponse(resp); > > } > > /* > > * Hand the request over to the real server so that targeted servic= e can > > be > > * executed. > > */ > > _handler.handle(req, resp); > > } > > } > > > > -------------------- > > And the GZipRequest and GZipResponse are mainly a wrapper on a request = where > > stream getter methods return a GZIP stream: > > > > > > public class GZipRequest implements Request { //extends FilterRequest { > > private int _size; > > private Request _req; > > > > // =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > // Constructor > > // =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > > > /** > > * Wraps the specified request stream into a GZipStream. > > */ > > public GZipRequest(Request request, int size) { > > //super(request); > > _req =3D request; > > if (size <=3D0) { > > _size =3D 2048; > > } else { > > _size =3D size; > > } > > } > > > > // =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > // Public methods > > // =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > > > /** > > * Returns a GZIPInputStream. > > */ > > public InputStream getInputStream() throws IOException { > > return new GZIPInputStream(_req.getInputStream(), _size); > > } > > > > /** > > * This can be used to get the URI specified for this HTTP > > * request. This corresponds to the /index part of a > > * http://www.domain.com/index URL but may contain the full > > * URL. This can be set using <code>setURI</code>. > > * > > * @return the URI that this HTTP request is targeting > > */ > > public String getURI(){ > > return _req.getURI(); > > } > > > > /** > > * This can be used to set the URI for this HTTP request. > > * The <code>getURI</code> will return the String entered > > * which can be a full HTTP URL or a relative path URL. > > * > > * @param uri the URI that this HTTP request is to use > > */ > > public void setURI(String uri){ > > _req.setURI(uri); > > } > > > > /** > > * This can be used to get the HTTP method for this > > * request. The HTTP specification RFC 2616 specifies the > > * HTTP request methods in section 9, Method Definitions. > > * > > * @return the request method for this request > > */ > > public String getMethod(){ > > return _req.getMethod(); > > } > > > > ... > > > > ------------------ > > > > public class GZipResponse implements Response { //extends FilterRespons= e { > > private Response _resp; > > > > // =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > // Constructors > > // =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > > > /** > > * Creates a GZipResponse for the specified Response. > > */ > > public GZipResponse(Response response) { > > //super(response); > > _resp =3D response; > > _resp.set("Content-Encoding", "gzip"); > > } > > > > // =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > // Public methods > > // =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > > > /** > > * Returns a GZIPOutputStream. > > * @see simple.http.Response#getOutputStream() > > */ > > public OutputStream getOutputStream() throws IOException { > > return new GZIPOutputStream(_resp.getOutputStream()); > > } > > > > /** > > * Returns a GZIPOutputStream. > > * @see simple.http.Response#getOutputStream(int) > > */ > > public OutputStream getOutputStream(int size) throws IOException { > > return new GZIPOutputStream(_resp.getOutputStream(size), size); > > } > > > > /** > > * Returns a GZIPOutputStream wrapped into a PrintStream. > > * @see simple.http.Response#getPrintStream() > > */ > > public PrintStream getPrintStream() throws IOException { > > return getPrintStream(); > > } > > > > /** > > * Returns a GZIPOutputStream wrapped into a PrintStream. > > * @see simple.http.Response#getPrintStream(int) > > */ > > public PrintStream getPrintStream(int size) throws IOException { > > return new PrintStream(getOutputStream(size), false); > > } > > > > /** > > * This represents the status code of the HTTP response. The HTTP > > * response code represents the type of message that is being sent > > * to the client. For a description of the codes see RFC 2616 > > * section 10, Status Code Definitions. > > * > > * @return the status code that this HTTP response has > > */ > > public int getCode(){ > > return _resp.getCode(); > > } > > > > /** > > * This method allows the status for the response to be changed. > > * This must be reflected the the response content given to the > > * client. For a description of the codes see RFC 2616 section > > * 10, Status Code Definitions. > > * > > * @param code the new status code for the HTTP response > > */ > > public void setCode(int code){ > > _resp.setCode(code); > > } > > > > .... > > > > Christophe > > > -----Original Message----- > > > From: sim...@li... [mailto:simpleweb= - > > > sup...@li...] On Behalf Of Brian Davis > > > Sent: Tuesday, December 13, 2005 10:20 AM > > > To: sim...@li... > > > Subject: [Simpleweb-Support] HTTP Compression > > > > > > Is there any plans to support gzip or deflate.. or is it there and I > > > am not finding it.. also.. if not why? and.. if not.. any recommends > > > on where to add it.. > > > > > > thanks! > > > > > > Brian > > > > > > > > > ------------------------------------------------------- > > > This SF.net email is sponsored by: Splunk Inc. Do you grep through lo= g > > > files > > > for problems? Stop! Download the new AJAX search engine that makes > > > searching your log files as easy as surfing the web. DOWNLOAD SPLUN= K! > > > http://ads.osdn.com/?ad_idv37&alloc_id=16865&op=3Dick > > > _______________________________________________ > > > Simpleweb-Support mailing list > > > Sim...@li... > > > https://lists.sourceforge.net/lists/listinfo/simpleweb-support > > > > > > > > > > > > ------------------------------------------------------- > > This SF.net email is sponsored by: Splunk Inc. Do you grep through log = files > > for problems? Stop! Download the new AJAX search engine that makes > > searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! > > http://ads.osdn.com/?ad_idv37&alloc_id=16865&opclick > > _______________________________________________ > > Simpleweb-Support mailing list > > Sim...@li... > > https://lists.sourceforge.net/lists/listinfo/simpleweb-support > > > |
From: Niall G. <gal...@ya...> - 2005-12-14 21:45:58
|
Hi Brian, Take a look a http://zoe.nu, this uses compression with Simple. I did implement compression in Simple, I was not impressed with the performance results and it added complexity I did not need. Also, compression is not always best implemented in the Response object. I am unsure how you are serving content. However encoding in a cache, or file system interface is a good solution. For example: public class GzipContent implements Content { public GzipContent(SomeSource source) { // set up your source } public void write(OutputStream out) { compressedBytes = // get from cache or dynamic source out.write(compressedBytes); } public String getMimeType() { return "text/html; charset=utf-8" } public String getEncoding() { return "gzip"; } } This allows you to use the object to transfer info and meta-data easily, also it gives you more choice in what gets compressed. Niall --- Brian Davis <wic...@gm...> wrote: > Hmm... can't seem to get this to work.. > > also a couple things bother me... first.. in order > to do it this way I > won't be able to set the content-length because > whatever i set would > be wrong.. also.. compression should be handled at > the framework level > if possible.. so.. I was really just wondering why > it wasn't > supported... out of the box per-se > > anyway.. thanks for the help! > > /Brian > > On 12/13/05, Brian Davis <wic...@gm...> > wrote: > > Hey cool.. I will look at this in a day or two and > let you know how it > > goes.. did you guys do anything with deflate or > just gzip? > > > > /Brian > > > > > > On 12/13/05, Christophe Roudet > <cr...@ac...> wrote: > > > I have done this with a custom ProtocolHandler: > > > > > > public class ServerHandler implements > ProtocolHandler { > > > private ProtocolHandler _handler; > > > private static final Logger _logger = > > > Logger.getLogger(ServerHandler.class); > > > > > > // ============= > > > // Constructor > > > // ============= > > > > > > public ServerHandler(ProtocolHandler handler) > { > > > _handler = handler; > > > } > > > > > > // =============== > > > // Public methods > > > // =============== > > > > > > public void handle(Request req, Response resp) > { > > > resp.set("Server", "Simple"); > > > resp.setDate("Date", > System.currentTimeMillis()); > > > // check for compressed request > > > String contentEncoding = > req.getValue("Content-Encoding"); > > > if ((contentEncoding != null) > > > && > (contentEncoding.toLowerCase().indexOf("gzip") > > -1)) { > > > _logger.debug("Request is zipped."); > > > req = new GZipRequest(req, > SimpleWeb.BUFFER_SIZE); > > > } > > > // does the client accept compressed > response? > > > String acceptEncoding = > req.getValue("Accept-Encoding"); > > > if ((!"GET".equals(req.getMethod())) && > (acceptEncoding != null) > > > && > (acceptEncoding.toLowerCase().indexOf("gzip") > -1)) > { > > > _logger.debug("Response will be zipped."); > > > resp = new GZipResponse(resp); > > > } > > > /* > > > * Hand the request over to the real server > so that targeted service can > > > be > > > * executed. > > > */ > > > _handler.handle(req, resp); > > > } > > > } > > > > > > -------------------- > > > And the GZipRequest and GZipResponse are mainly > a wrapper on a request where > > > stream getter methods return a GZIP stream: > > > > > > > > > public class GZipRequest implements Request { > //extends FilterRequest { > > > private int _size; > > > private Request _req; > > > > > > // ============= > > > // Constructor > > > // ============= > > > > > > /** > > > * Wraps the specified request stream into a > GZipStream. > > > */ > > > public GZipRequest(Request request, int size) > { > > > //super(request); > > > _req = request; > > > if (size <=0) { > > > _size = 2048; > > > } else { > > > _size = size; > > > } > > > } > > > > > > // =============== > > > // Public methods > > > // =============== > > > > > > /** > > > * Returns a GZIPInputStream. > > > */ > > > public InputStream getInputStream() throws > IOException { > > > return new > GZIPInputStream(_req.getInputStream(), _size); > > > } > > > > > > /** > > > * This can be used to get the URI specified > for this HTTP > > > * request. This corresponds to the /index > part of a > > > * http://www.domain.com/index URL but may > contain the full > > > * URL. This can be set using > <code>setURI</code>. > > > * > > > * @return the URI that this HTTP request is > targeting > > > */ > > > public String getURI(){ > > > return _req.getURI(); > > > } > > > > > > /** > > > * This can be used to set the URI for this > HTTP request. > > > * The <code>getURI</code> will return the > String entered > > > * which can be a full HTTP URL or a relative > path URL. > > > * > > > * @param uri the URI that this HTTP request > is to use > > > */ > > > public void setURI(String uri){ > > > _req.setURI(uri); > > > } > > > > > > /** > > > * This can be used to get the HTTP method for > this > > > * request. The HTTP specification RFC 2616 > specifies the > > > * HTTP request methods in section 9, Method > Definitions. > > > * > > > * @return the request method for this request > > > */ > > > public String getMethod(){ > > > return _req.getMethod(); > > > } > > > > > > ... > > > > > > ------------------ > > > > > > public class GZipResponse implements Response { > //extends FilterResponse { > > > private Response _resp; > > > > > > // ============= > > > // Constructors > > > // ============= > > > > > > /** > > > * Creates a GZipResponse for the specified > Response. > > > */ > > > public GZipResponse(Response response) { > > > //super(response); > > > _resp = response; > > > _resp.set("Content-Encoding", "gzip"); > > > } > > > > > > // ============== > > > // Public methods > > > // =============== > === message truncated === Niall Gallagher __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |
From: petite_abeille <pet...@ma...> - 2005-12-17 13:27:54
|
Hello, On Dec 14, 2005, at 22:45, Niall Gallagher wrote: > Take a look a http://zoe.nu, this uses compression > with Simple. ZO=CB uses a very straightforward approach: http://dev.alt.textdrive.com/file/ZOE/Frameworks/SZApp/=20 SZContentEncoder.java For something slightly more sophisticated (including conditional =20 responses), take a look at LWResponse:handleContent(): http://dev.alt.textdrive.com/file/LW/LWResponse.lua > I did implement compression in Simple, I > was not impressed with the performance results and it > added complexity I did not need. =46rom my personal experience, response compression do make sense when =20= the network bandwidth is either a bottleneck or a significant monetary =20= cost of running your application. Or both :) Of course, your mileage =20= may vary according to your particular circumstances. Regarding if this should be supported by an HTTP framework =20 "out-of-the-box", I would venture that yes, it should :) "The third principle is that web.py should, by default, do the right =20 thing by the Web" [sic] -- Aaron Swartz, "Rewriting Reddit", December 6 2005 http://www.aaronsw.com/weblog/rewritingreddit As Spike Lee might have said [1], "doing the right thing" would include =20= handling most, if not all, the drudgery of HTTP mannerisms. Cheers -- PA, Onnay Equitursay http://alt.textdrive.com/ [1] http://www.imdb.com/title/tt0097216/ |
From: Brian D. <wic...@gm...> - 2005-12-18 19:00:53
|
Hi.. thanks for the input.. current results below... public void test1006() throws Exception { File dir =3D new File("test/carol"); File[] list =3D dir.listFiles(); for (int i =3D 0; i < list.length; i++) { File tmp =3D list[i]; String path =3D tmp.getAbsolutePath(); int x =3D path.lastIndexOf('/'); if (x !=3D -1) { path =3D path.substring(x+1); } HttpClient client =3D new HttpClient(); HttpMethod method =3D new GetMethod("http://127.0.0.1:2000/carol/" + path); try { int status =3D client.executeMethod(method); byte[] body =3D method.getResponseBody(); Assert.assertTrue(status =3D=3D 200); } catch (Exception ex) { throw ex; } finally { method.releaseConnection(); } } } 127.0.0.1 - - [18/Dec/2005:18:52:57 -0000] "GET /carol/contents.doc HTTP/1.1" 200 19968 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:52:57 -0000] "GET /carol/contents.html HTTP/1.1" 200 607 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:52:57 -0000] "GET /carol/contents.pdf HTTP/1.1" 200 8140 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:52:57 -0000] "GET /carol/contents.txt HTTP/1.1" 200 188 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:52:57 -0000] "GET /carol/preface.doc HTTP/1.1" 200 19968 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:52:57 -0000] "GET /carol/preface.html HTTP/1.1" 200 830 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:52:57 -0000] "GET /carol/preface.pdf HTTP/1.1" 200 8467 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:52:57 -0000] "GET /carol/preface.txt HTTP/1.1" 200 366 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:52:57 -0000] "GET /carol/stave1.doc HTTP/1.1" 200 88064 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:52:57 -0000] "GET /carol/stave1.html HTTP/1.1" 200 38755 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:52:57 -0000] "GET /carol/stave1.pdf HTTP/1.1" 200 76956 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:52:57 -0000] "GET /carol/stave1.txt HTTP/1.1" 200 37092 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:52:57 -0000] "GET /carol/stave2.doc HTTP/1.1" 200 80896 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:52:57 -0000] "GET /carol/stave2.html HTTP/1.1" 200 36186 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:52:57 -0000] "GET /carol/stave2.pdf HTTP/1.1" 200 67731 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:52:57 -0000] "GET /carol/stave2.txt HTTP/1.1" 200 34739 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:52:57 -0000] "GET /carol/stave3.doc HTTP/1.1" 200 100352 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:52:57 -0000] "GET /carol/stave3.html HTTP/1.1" 200 48604 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:52:57 -0000] "GET /carol/stave3.pdf HTTP/1.1" 200 85185 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:52:58 -0000] "GET /carol/stave3.txt HTTP/1.1" 200 47176 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:52:58 -0000] "GET /carol/stave4.doc HTTP/1.1" 200 74240 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:52:58 -0000] "GET /carol/stave4.html HTTP/1.1" 200 31303 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:52:58 -0000] "GET /carol/stave4.pdf HTTP/1.1" 200 62070 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:52:58 -0000] "GET /carol/stave4.txt HTTP/1.1" 200 29757 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:52:58 -0000] "GET /carol/stave5.doc HTTP/1.1" 200 38400 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:52:58 -0000] "GET /carol/stave5.html HTTP/1.1" 200 13697 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:52:58 -0000] "GET /carol/stave5.pdf HTTP/1.1" 200 31047 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:52:58 -0000] "GET /carol/stave5.txt HTTP/1.1" 200 12818 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:52:58 -0000] "GET /carol/title.doc HTTP/1.1" 200 19968 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:52:58 -0000] "GET /carol/title.html HTTP/1.1" 200 447 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:52:58 -0000] "GET /carol/title.pdf HTTP/1.1" 200 8150 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:52:58 -0000] "GET /carol/title.txt HTTP/1.1" 200 88 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 // test gzip public void test7001() throws Exception { File dir =3D new File("test/carol"); File[] list =3D dir.listFiles(); for (int i =3D 0; i < list.length; i++) { File tmp =3D list[i]; String path =3D tmp.getAbsolutePath(); int x =3D path.lastIndexOf('/'); if (x !=3D -1) { path =3D path.substring(x+1); } HttpClient client =3D new HttpClient(); HttpMethod method =3D new GetMethod("http://127.0.0.1:2000/carol/" + path); method.setRequestHeader("Accept-Encoding", "gzip"); try { int status =3D client.executeMethod(method); byte[] body =3D method.getResponseBody(); if (method.getResponseHeader("Content-Encoding") !=3D null && method.getResponseHeader("Content-Encoding").getValue().equals("gzi= p")) { System.err.println("GZIP MY FRIEND " + path); GZIPInputStream in =3D new GZIPInputStream(new ByteArrayInputStream(body)); byte[] decoded =3D new byte[Integer.parseInt(method.getResponseHeader("Content-Length").getValue()= )]; in.read(decoded, 0, decoded.length); } Assert.assertTrue(status =3D=3D 200); } catch (Exception ex) { throw ex; } finally { method.releaseConnection(); } } } 127.0.0.1 - - [18/Dec/2005:18:52:58 -0000] "GET /carol/contents.doc HTTP/1.1" 200 2043 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:52:58 -0000] "GET /carol/contents.html HTTP/1.1" 200 379 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:52:59 -0000] "GET /carol/contents.pdf HTTP/1.1" 200 2900 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:52:59 -0000] "GET /carol/contents.txt HTTP/1.1" 200 124 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:52:59 -0000] "GET /carol/preface.doc HTTP/1.1" 200 2171 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:52:59 -0000] "GET /carol/preface.html HTTP/1.1" 200 541 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:52:59 -0000] "GET /carol/preface.pdf HTTP/1.1" 200 3158 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:52:59 -0000] "GET /carol/preface.txt HTTP/1.1" 200 250 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:52:59 -0000] "GET /carol/stave1.doc HTTP/1.1" 200 23319 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:52:59 -0000] "GET /carol/stave1.html HTTP/1.1" 200 16154 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:53:00 -0000] "GET /carol/stave1.pdf HTTP/1.1" 200 45454 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:53:00 -0000] "GET /carol/stave1.txt HTTP/1.1" 200 15662 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:53:00 -0000] "GET /carol/stave2.doc HTTP/1.1" 200 21556 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:53:00 -0000] "GET /carol/stave2.html HTTP/1.1" 200 15066 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:53:00 -0000] "GET /carol/stave2.pdf HTTP/1.1" 200 40428 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:53:00 -0000] "GET /carol/stave2.txt HTTP/1.1" 200 14623 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:53:00 -0000] "GET /carol/stave3.doc HTTP/1.1" 200 27909 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:53:00 -0000] "GET /carol/stave3.html HTTP/1.1" 200 20182 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:53:00 -0000] "GET /carol/stave3.pdf HTTP/1.1" 200 51863 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:53:00 -0000] "GET /carol/stave3.txt HTTP/1.1" 200 19720 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:53:00 -0000] "GET /carol/stave4.doc HTTP/1.1" 200 19062 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:53:00 -0000] "GET /carol/stave4.pdf HTTP/1.1" 200 36394 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:53:00 -0000] "GET /carol/stave4.html HTTP/1.1" 200 13008 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:53:00 -0000] "GET /carol/stave4.txt HTTP/1.1" 200 12568 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:53:00 -0000] "GET /carol/stave5.doc HTTP/1.1" 200 8748 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:53:00 -0000] "GET /carol/stave5.html HTTP/1.1" 200 5980 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:53:00 -0000] "GET /carol/stave5.txt HTTP/1.1" 200 5619 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:53:00 -0000] "GET /carol/stave5.pdf HTTP/1.1" 200 17410 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:53:00 -0000] "GET /carol/title.doc HTTP/1.1" 200 2033 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:53:01 -0000] "GET /carol/title.html HTTP/1.1" 200 340 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:53:01 -0000] "GET /carol/title.pdf HTTP/1.1" 200 2885 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 127.0.0.1 - - [18/Dec/2005:18:53:01 -0000] "GET /carol/title.txt HTTP/1.1" 200 88 "" "Jakarta Commons-HttpClient/3.0-rc4" 127.0.0.1:2000 public class GZipEncoder { public GZipEncoder(Request req, Response res) { _req =3D req; _res =3D res; } public byte[] encode(byte[] data) { if (String.valueOf(_req.getValue("Accept-Encoding")).toLowerCase().= indexOf("gzip") !=3D -1) { ByteArrayOutputStream bout =3D new ByteArrayOutputStream(); GZIPOutputStream out =3D null; try { out =3D new GZIPOutputStream(bout); out.write(data, 0, data.length); out.finish(); } catch (Exception ex) { } finally { try { out.close(); } catch (Exception ex) { } } byte[] tmp =3D bout.toByteArray(); if (tmp.length < data.length) { _res.set("Content-Encoding", "gzip"); _res.set("Vary", "Accept-Encoding"); return tmp; } } return data; } private Request _req; private Response _res; } public final class GZipFileResource extends ContentResource { public GZipFileResource(Context context, String target){ super(context, target); } protected void process(Request req, Response resp)throws Exception { if(req.getDate("If-Modified-Since")< getLastModified()){ resp.setDate("Date", System.currentTimeMillis()); resp.setDate("Last-Modified",getLastModified()); resp.set("Content-Type",type); ByteArrayOutputStream bout =3D new ByteArrayOutputStream(); write(bout); GZipEncoder encoder =3D new GZipEncoder(req, resp); byte[] data =3D encoder.encode(bout.toByteArray()); resp.setContentLength(data.length); if (req.getMethod().equals("HEAD")) { resp.commit(); } else if (req.getMethod().equals("GET")) { resp.getOutputStream().write(data, 0, data.length); resp.getOutputStream().close(); } else { handle(req,resp,501); } }else { handle(req,resp,304); } } } /hear's the beegee's On 12/17/05, petite_abeille <pet...@ma...> wrote: > Hello, > > On Dec 14, 2005, at 22:45, Niall Gallagher wrote: > > > Take a look a http://zoe.nu, this uses compression > > with Simple. > > ZO=CB uses a very straightforward approach: > > http://dev.alt.textdrive.com/file/ZOE/Frameworks/SZApp/ > SZContentEncoder.java > > For something slightly more sophisticated (including conditional > responses), take a look at LWResponse:handleContent(): > > http://dev.alt.textdrive.com/file/LW/LWResponse.lua > > > I did implement compression in Simple, I > > was not impressed with the performance results and it > > added complexity I did not need. > > From my personal experience, response compression do make sense when > the network bandwidth is either a bottleneck or a significant monetary > cost of running your application. Or both :) Of course, your mileage > may vary according to your particular circumstances. > > Regarding if this should be supported by an HTTP framework > "out-of-the-box", I would venture that yes, it should :) > > "The third principle is that web.py should, by default, do the right > thing by the Web" [sic] > -- Aaron Swartz, "Rewriting Reddit", December 6 2005 > http://www.aaronsw.com/weblog/rewritingreddit > > As Spike Lee might have said [1], "doing the right thing" would include > handling most, if not all, the drudgery of HTTP mannerisms. > > Cheers > > -- > PA, Onnay Equitursay > http://alt.textdrive.com/ > > [1] http://www.imdb.com/title/tt0097216/ > > > > > > > > > > ------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. Do you grep through log fi= les > for problems? Stop! Download the new AJAX search engine that makes > searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! > http://ads.osdn.com/?ad_idv37&alloc_id=16865&opclick > _______________________________________________ > Simpleweb-Support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simpleweb-support > |
From: Carfield Y. <car...@ca...> - 2006-01-14 04:28:42
|
Try to implement HTTP compression, it work fine at all browser I've accessable: safari, firefox, opera, internet explorer. However, there are still socket exception and I don't know why: java.io.IOException: Stream closed at simple.http.MonitoredOutputStream.ensureOpen(Unknown Source) at simple.http.MonitoredOutputStream.write(Unknown Source) at simple.http.ResponseStream.write(Unknown Source) at java.util.zip.GZIPOutputStream.finish(GZIPOutputStream.java:95) at java.util.zip.DeflaterOutputStream.close(DeflaterOutputStream.jav= a:141) at hk.com.carfield.web.simple.Controller.rawDisplay(Controller.java:= 126) at hk.com.carfield.web.simple.Controller.handleRequest(Controller.ja= va:64) at hk.com.carfield.web.simple.Controller.process(Controller.java:137= ) at simple.http.serve.BasicResource.handle(Unknown Source) at simple.http.serve.ResourceProcessor.handle(Unknown Source) at simple.http.Dispatcher.run(Unknown Source) at simple.util.process.Daemon.execute(Unknown Source) at simple.util.process.Daemon.run(Unknown Source) And method rawDisplay is just a method to show the file content directly: =09private void rawDisplay(Response res, File location) throws IOException, =09=09=09FileNotFoundException { =09=09res.set("Content-Encoding", "gzip"); =09=09res.set("Vary", "Accept-Encoding"); =09=09if (location.isFile()) { =09=09=09final InputStream is =3D new FileInputStream(location); =09=09=09final OutputStream os =3D res.getOutputStream(); =09=09=09OutputStream gos =3D null; =09=09=09try { =09=09=09=09gos =3D new GZIPOutputStream(os); =09=09=09=09final String mime =3D context.getMimeType(location.getName()); =09=09=09=09res.set("Content-Type", mime); =09=09=09=09IOUtils.copy(is, gos); =09=09=09} finally { =09=09=09=09is.close(); =09=09=09=09if(gos !=3D null) =09=09=09=09=09gos.close(); =09=09=09=09else =09=09=09=09=09os.close(); =09=09=09} =09=09} =09} The other exception is: java.lang.RuntimeException: java.io.IOException: Stream closed at hk.com.carfield.web.simple.Controller.setDocument(Controller.java= :100) at hk.com.carfield.web.simple.Controller.handleRequest(Controller.ja= va:69) at hk.com.carfield.web.simple.Controller.process(Controller.java:137= ) at simple.http.serve.BasicResource.handle(Unknown Source) at simple.http.serve.ResourceProcessor.handle(Unknown Source) at simple.http.Dispatcher.run(Unknown Source) at simple.util.process.Daemon.execute(Unknown Source) at simple.util.process.Daemon.run(Unknown Source) Caused by: java.io.IOException: Stream closed at simple.http.MonitoredOutputStream.ensureOpen(Unknown Source) at simple.http.MonitoredOutputStream.write(Unknown Source) at simple.http.ResponseStream.write(Unknown Source) at java.io.OutputStream.write(OutputStream.java:58) at java.util.zip.GZIPOutputStream.writeHeader(GZIPOutputStream.java:= 123) at java.util.zip.GZIPOutputStream.<init>(GZIPOutputStream.java:48) at java.util.zip.GZIPOutputStream.<init>(GZIPOutputStream.java:58) at hk.com.carfield.web.simple.Controller.setDocument(Controller.java= :97) ... 7 more =09private void setDocument(Response response, =09=09=09Document document) throws IOException { =09=09res.set("Content-Encoding", "gzip"); =09=09res.set("Vary", "Accept-Encoding"); =09=09final OutputStream os =3D response.getOutputStream(); =09=09OutputStream gos =3D null; =09=09try { =09=09=09gos =3D new GZIPOutputStream(os); =09=09=09document.write(gos); =09=09} catch (Exception e) { =09=09=09throw new RuntimeException(e); =09=09} finally { =09=09=09if(gos !=3D null) =09=09=09=09gos.close(); =09=09=09else =09=09=09=09os.close(); =09=09} =09} Anyone have any idea? |
From: Niall G. <gal...@ya...> - 2006-01-14 10:34:13
|
Hi Carfield, It seems as if the client has asynchronously closed the connection, either due to a browser refresh or perhaps some other I/O event. To investigate this further edit the MonitoredOutputStream.java source for Simple. Modify the destroy() method to become destroy(IOException e) and pass all exceptions to the destroy method. The you can throw these exceptions, which contain the specific error....this is something I should have done from the out set. For example: protected void destroy(IOException cause) throws IOException { if(open) { open = false; } throw cause; } This will provide the exact stack trace. Niall --- Carfield Yim <car...@ca...> wrote: > Try to implement HTTP compression, it work fine at > all browser I've > accessable: safari, firefox, opera, internet > explorer. However, there > are still socket exception and I don't know why: > > > java.io.IOException: Stream closed > at > simple.http.MonitoredOutputStream.ensureOpen(Unknown > Source) > at > simple.http.MonitoredOutputStream.write(Unknown > Source) > at simple.http.ResponseStream.write(Unknown > Source) > at > java.util.zip.GZIPOutputStream.finish(GZIPOutputStream.java:95) > at > java.util.zip.DeflaterOutputStream.close(DeflaterOutputStream.java:141) > at > hk.com.carfield.web.simple.Controller.rawDisplay(Controller.java:126) > at > hk.com.carfield.web.simple.Controller.handleRequest(Controller.java:64) > at > hk.com.carfield.web.simple.Controller.process(Controller.java:137) > at > simple.http.serve.BasicResource.handle(Unknown > Source) > at > simple.http.serve.ResourceProcessor.handle(Unknown > Source) > at simple.http.Dispatcher.run(Unknown Source) > at simple.util.process.Daemon.execute(Unknown > Source) > at simple.util.process.Daemon.run(Unknown > Source) > > And method rawDisplay is just a method to show the > file content directly: > > > private void rawDisplay(Response res, File > location) throws IOException, > FileNotFoundException { > res.set("Content-Encoding", "gzip"); > res.set("Vary", "Accept-Encoding"); > if (location.isFile()) { > final InputStream is = new > FileInputStream(location); > final OutputStream os = res.getOutputStream(); > OutputStream gos = null; > try { > gos = new GZIPOutputStream(os); > final String mime = > context.getMimeType(location.getName()); > res.set("Content-Type", mime); > IOUtils.copy(is, gos); > } finally { > is.close(); > if(gos != null) > gos.close(); > else > os.close(); > } > } > } > > > The other exception is: > > java.lang.RuntimeException: java.io.IOException: > Stream closed > at > hk.com.carfield.web.simple.Controller.setDocument(Controller.java:100) > at > hk.com.carfield.web.simple.Controller.handleRequest(Controller.java:69) > at > hk.com.carfield.web.simple.Controller.process(Controller.java:137) > at > simple.http.serve.BasicResource.handle(Unknown > Source) > at > simple.http.serve.ResourceProcessor.handle(Unknown > Source) > at simple.http.Dispatcher.run(Unknown Source) > at simple.util.process.Daemon.execute(Unknown > Source) > at simple.util.process.Daemon.run(Unknown > Source) > Caused by: java.io.IOException: Stream closed > at > simple.http.MonitoredOutputStream.ensureOpen(Unknown > Source) > at > simple.http.MonitoredOutputStream.write(Unknown > Source) > at simple.http.ResponseStream.write(Unknown > Source) > at > java.io.OutputStream.write(OutputStream.java:58) > at > java.util.zip.GZIPOutputStream.writeHeader(GZIPOutputStream.java:123) > at > java.util.zip.GZIPOutputStream.<init>(GZIPOutputStream.java:48) > at > java.util.zip.GZIPOutputStream.<init>(GZIPOutputStream.java:58) > at > hk.com.carfield.web.simple.Controller.setDocument(Controller.java:97) > ... 7 more > > > private void setDocument(Response response, > Document document) throws IOException { > res.set("Content-Encoding", "gzip"); > res.set("Vary", "Accept-Encoding"); > final OutputStream os = > response.getOutputStream(); > OutputStream gos = null; > try { > gos = new GZIPOutputStream(os); > document.write(gos); > } catch (Exception e) { > throw new RuntimeException(e); > } finally { > if(gos != null) > gos.close(); > else > os.close(); > } > } > > Anyone have any idea? > > > ------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. Do > you grep through log files > for problems? Stop! Download the new AJAX search > engine that makes > searching your log files as easy as surfing the > web. DOWNLOAD SPLUNK! > http://ads.osdn.com/?ad_idv37&alloc_id865&op=click > _______________________________________________ > Simpleweb-Support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simpleweb-support > Niall Gallagher __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |
From: Carfield Y. <car...@gm...> - 2006-01-15 17:49:39
|
SSBzZWUsIGhvd2V2ZXIsIG9uY2UgSSBwdXQgdGhlIGNoYW5nZSBhbmQgY29tcGlsZS4uLiBJIGdl dCBhIHZlcnkKc3RyYW5nbGUgcHJvYmxlbToKCmNsZWFuOgogICBbZGVsZXRlXSBEZWxldGluZyBk aXJlY3RvcnkgL1VzZXJzL2NhcmZpZWxkL0Rlc2t0b3Avc2ltcGxlLTIuOC4xL2J1aWxkCiAgIFtk ZWxldGVdIERlbGV0aW5nIGRpcmVjdG9yeSAvVXNlcnMvY2FyZmll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QtVHlwZSIsIG1pbWUpOwo+ID4gICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgSU9VdGlscy5jb3B5KGlzLCBnb3MpOwo+ID4gICAgICAgICAgICAgICAgICAg ICAgIH0gZmluYWxseSB7Cj4gPiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpcy5jbG9z ZSgpOwo+ID4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYoZ29zICE9IG51bGwpCj4g PiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdvcy5jbG9zZSgpOwo+ID4g ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxzZQo+ID4gICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICBvcy5jbG9zZSgpOwo+ID4gICAgICAgICAgICAgICAgICAgICAg IH0KPiA+ICAgICAgICAgICAgICAgfQo+ID4gICAgICAgfQo+ID4KPiA+Cj4gPiBUaGUgb3RoZXIg ZXhjZXB0aW9uIGlzOgo+ID4KPiA+IGphdmEubGFuZy5SdW50aW1lRXhjZXB0aW9uOiBqYXZhLmlv LklPRXhjZXB0aW9uOgo+ID4gU3RyZWFtIGNsb3NlZAo+ID4gICAgICAgIGF0Cj4gPgo+IGhrLmNv bS5jYXJmaWVsZC53ZWIuc2ltcGxlLkNvbnRyb2xsZXIuc2V0RG9jdW1lbnQoQ29udHJvbGxlci5q YXZhOjEwMCkKPiA+ICAgICAgICBhdAo+ID4KPiBoay5jb20uY2FyZmllbGQud2ViLnNpbXBsZS5D b250cm9sbGVyLmhhbmRsZVJlcXVlc3QoQ29udHJvbGxlci5qYXZhOjY5KQo+ID4gICAgICAgIGF0 Cj4gPgo+IGhrLmNvbS5jYXJmaWVsZC53ZWIuc2ltcGxlLkNvbnRyb2xsZXIucHJvY2VzcyhDb250 cm9sbGVyLmphdmE6MTM3KQo+ID4gICAgICAgIGF0Cj4gPiBzaW1wbGUuaHR0cC5zZXJ2ZS5CYXNp Y1Jlc291cmN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0uamF2YTo0OCkKPiA+ICAgICAgICBhdAo+ID4KPiBqYXZhLnV0 aWwuemlwLkdaSVBPdXRwdXRTdHJlYW0uPGluaXQ+KEdaSVBPdXRwdXRTdHJlYW0uamF2YTo1OCkK PiA+ICAgICAgICBhdAo+ID4KPiBoay5jb20uY2FyZmllbGQud2ViLnNpbXBsZS5Db250cm9sbGVy LnNldERvY3VtZW50KENvbnRyb2xsZXIuamF2YTo5NykKPiA+ICAgICAgICAuLi4gNyBtb3JlCj4g Pgo+ID4KPiA+ICAgICAgIHByaXZhdGUgdm9pZCBzZXREb2N1bWVudChSZXNwb25zZSByZXNwb25z ZSwKPiA+ICAgICAgICAgICAgICAgICAgICAgICBEb2N1bWVudCBkb2N1bWVudCkgdGhyb3dzIElP RXhjZXB0aW9uIHsKPiA+ICAgICAgICAgICAgICAgcmVzLnNldCgiQ29udGVudC1FbmNvZGluZyIs ICJnemlwIik7Cj4gPiAgICAgICAgICAgICAgIHJlcy5zZXQoIlZhcnkiLCAiQWNjZXB0LUVuY29k aW5nIik7Cj4gPiAgICAgICAgICAgICAgIGZpbmFsIE91dHB1dFN0cmVhbSBvcyA9Cj4gPiByZXNw b25zZS5nZXRPdXRwdXRTdHJlYW0oKTsKPiA+ICAgICAgICAgICAgICAgT3V0cHV0U3RyZWFtIGdv cyA9IG51bGw7Cj4gPiAgICAgICAgICAgICAgIHRyeSB7Cj4gPiAgICAgICAgICAgICAgICAgICAg ICAgZ29zID0gbmV3IEdaSVBPdXRwdXRTdHJlYW0ob3MpOwo+ID4gICAgICAgICAgICAgICAgICAg ICAgIGRvY3VtZW50LndyaXRlKGdvcyk7Cj4gPiAgICAgICAgICAgICAgIH0gY2F0Y2ggKEV4Y2Vw dGlvbiBlKSB7Cj4gPiAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IFJ1bnRpbWVFeGNl cHRpb24oZSk7Cj4gPiAgICAgICAgICAgICAgIH0gZmluYWxseSB7Cj4gPiAgICAgICAgICAgICAg IC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19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fCj4gRG8gWW91IFlhaG9vIT8KPiBUaXJlZCBvZiBzcGFtPyAgWWFob28hIE1haWwgaGFzIHRo ZSBiZXN0IHNwYW0gcHJvdGVjdGlvbiBhcm91bmQKPiBodHRwOi8vbWFpbC55YWhvby5jb20KPgo+ Cj4gLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LQo+IFRoaXMgU0YubmV0IGVtYWlsIGlzIHNwb25zb3JlZCBieTogU3BsdW5rIEluYy4gRG8geW91 IGdyZXAgdGhyb3VnaCBsb2cgZmlsZXMKPiBmb3IgcHJvYmxlbXM/ICBTdG9wISAgRG93bmxvYWQg dGhlIG5ldyBBSkFYIHNlYXJjaCBlbmdpbmUgdGhhdCBtYWtlcwo+IHNlYXJjaGluZyB5b3VyIGxv ZyBmaWxlcyBhcyBlYXN5IGFzIHN1cmZpbmcgdGhlICB3ZWIuICBET1dOTE9BRCBTUExVTkshCj4g aHR0cDovL2Fkcy5vc2RuLmNvbS8/YWRfaWQ9NzYzNyZhbGxvY19pZD0xNjg2NSZvcD1jbGljawo+ IF9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fCj4gU2ltcGxl d2ViLVN1cHBvcnQgbWFpbGluZyBsaXN0Cj4gU2ltcGxld2ViLVN1cHBvcnRAbGlzdHMuc291cmNl Zm9yZ2UubmV0Cj4gaHR0cHM6Ly9saXN0cy5zb3VyY2Vmb3JnZS5uZXQvbGlzdHMvbGlzdGluZm8v c2ltcGxld2ViLXN1cHBvcnQKPgo= |
From: Carfield Y. <car...@ca...> - 2006-01-15 17:51:35
|
I see, however, once I put the change and compile... I get a very strangle problem: clean: [delete] Deleting directory /Users/carfield/Desktop/simple-2.8.1/build [delete] Deleting directory /Users/carfield/Desktop/simple-2.8.1/jar prepare: [mkdir] Created dir: /Users/carfield/Desktop/simple-2.8.1/build [mkdir] Created dir: /Users/carfield/Desktop/simple-2.8.1/jar build: [javac] Compiling 258 source files to /Users/carfield/Desktop/simple-2.8.1/build [javac] /Users/carfield/Desktop/simple-2.8.1/src/simple/http/MonitoredOu= tputStream.java:1: 'class' or 'interface' expected [javac] /* [javac] ^ [javac] /Users/carfield/Desktop/simple-2.8.1/src/simple/http/MonitoredOu= tputStream.java:23: 'class' or 'interface' expected [javac] import java.io.OutputStream; [javac] ^ [javac] /Users/carfield/Desktop/simple-2.8.1/src/simple/http/MonitoredOu= tputStream.java:24: 'class' or 'interface' expected [javac] import java.io.IOException; [javac] ^ [javac] 3 errors The class is simple and I have totally no idea about this... BTW, I just double check with my old servlet version of implementation, there is similar problem, but I just ignore all that time. However, when I writing application at work, I never experience this... - Sho |