You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Nathan Beyer <nb...@kc.rr.com> on 2006/07/13 04:22:43 UTC

HTTP compression (http://jira.codehaus.org/browse/WAGON-55)

I tried posting this to the WAGON mailing list, but there doesn't seem to be
any activity over there...

I've posted some attachments to the JIRA issue WAGON-55 [1] to implement
support for accepting GZip-based compression with HTTP GETs for HTTP and
WebDAV. I'm hoping these simple changes can help to reduce some bandwidth
needs. I've seen some significant gains from my personal testing.

In any case, a major barrier to getting these patches approved and applied
is the lack of unit tests. I was able to test these patches myself using an
Apache HTTPD server and mod_deflate, but couldn't quite figure out the best
way to test in the JUnits. I tried setting up a Jetty embedded server and I
was able to get a test to execute, but I couldn't get Jetty to compress the
responses. Here's the test method I had so far trying to do this. If anyone
knows how to get this compressing the response, please let me know. Also,
any comments or suggestions on getting this test massaged to use the base
classes embedded server would be appreciated as well.


    public void testGzipGet()
        throws Exception
    {
        HttpServer server = new HttpServer();
        SocketListener listener = new SocketListener();
        listener.setPort(10008);
        server.addListener(listener);
        
        HttpContext context = new HttpContext();
        context.setContextPath("/");
        context.setResourceBase("c:/temp/");
        ResourceHandler rh = new ResourceHandler();
	  //The javadoc for these methods is confusing, does this compress
the response?
        rh.setMinGzipLength(1);
        context.addHandler(rh);
        server.addContext(context);
        server.start();
        try
        {
            HttpWagon wagon = new HttpWagon();
            Repository repo = new Repository();
            repo.setUrl("http://localhost:8080");
            repo.setId("gzip-temp");
            wagon.connect(repo);
            wagon.get("hello.txt", new File("c:/temp/hello-copy.txt"));
            wagon.disconnect();
        }
        finally
        {
            server.stop();
        }
    }


Thanks,
-Nathan Beyer

[1] http://jira.codehaus.org/browse/WAGON-55 [Provide support for HTTP
compression (request and response)]


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


RE: HTTP compression (http://jira.codehaus.org/browse/WAGON-55)

Posted by Nathan Beyer <nb...@kc.rr.com>.
Hello Eric,

That was it. It seems the ResourceHandler will look for the resource as with
a ".gz" and just streams that. So if you request "hello.txt" and
"hello.txt.gz" is on the server, it will send it back with Content-Encoding:
gzip in the response header.

-Nathan

> -----Original Message-----
> From: Eric Redmond [mailto:eric.redmond@gmail.com]
> Sent: Thursday, July 13, 2006 2:17 AM
> To: Maven Developers List
> Subject: Re: HTTP compression (http://jira.codehaus.org/browse/WAGON-55)
> 
> Hi Nathan;
> 
> It looks that the Jetty ResourceHandler will only return zipped content
> ending in ".gz", so perhaps its a simple as hello.txt.gz?
> (
> http://www.dpml.net/api/jetty/5.1.6/org/mortbay/http/handler/ResourceHandl
> er.html#setMinGzipLength(int)<http://www.dpml.net/api/jetty/5.1.6/org/mort
> bay/http/handler/ResourceHandler.html#setMinGzipLength%28int%29>)
> 
> Take care;
> Eric
> 
> On 7/12/06, Nathan Beyer <nb...@kc.rr.com> wrote:
> >
> > I tried posting this to the WAGON mailing list, but there doesn't seem
> to
> > be
> > any activity over there...
> >
> > I've posted some attachments to the JIRA issue WAGON-55 [1] to implement
> > support for accepting GZip-based compression with HTTP GETs for HTTP and
> > WebDAV. I'm hoping these simple changes can help to reduce some
> bandwidth
> > needs. I've seen some significant gains from my personal testing.
> >
> > In any case, a major barrier to getting these patches approved and
> applied
> > is the lack of unit tests. I was able to test these patches myself using
> > an
> > Apache HTTPD server and mod_deflate, but couldn't quite figure out the
> > best
> > way to test in the JUnits. I tried setting up a Jetty embedded server
> and
> > I
> > was able to get a test to execute, but I couldn't get Jetty to compress
> > the
> > responses. Here's the test method I had so far trying to do this. If
> > anyone
> > knows how to get this compressing the response, please let me know.
> Also,
> > any comments or suggestions on getting this test massaged to use the
> base
> > classes embedded server would be appreciated as well.
> >
> >
> >     public void testGzipGet()
> >         throws Exception
> >     {
> >         HttpServer server = new HttpServer();
> >         SocketListener listener = new SocketListener();
> >         listener.setPort(10008);
> >         server.addListener(listener);
> >
> >         HttpContext context = new HttpContext();
> >         context.setContextPath("/");
> >         context.setResourceBase("c:/temp/");
> >         ResourceHandler rh = new ResourceHandler();
> >           //The javadoc for these methods is confusing, does this
> compress
> > the response?
> >         rh.setMinGzipLength(1);
> >         context.addHandler(rh);
> >         server.addContext(context);
> >         server.start();
> >         try
> >         {
> >             HttpWagon wagon = new HttpWagon();
> >             Repository repo = new Repository();
> >             repo.setUrl("http://localhost:8080");
> >             repo.setId("gzip-temp");
> >             wagon.connect(repo);
> >             wagon.get("hello.txt", new File("c:/temp/hello-copy.txt"));
> >             wagon.disconnect();
> >         }
> >         finally
> >         {
> >             server.stop();
> >         }
> >     }
> >
> >
> > Thanks,
> > -Nathan Beyer
> >
> > [1] http://jira.codehaus.org/browse/WAGON-55 [Provide support for HTTP
> > compression (request and response)]
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> > For additional commands, e-mail: dev-help@maven.apache.org
> >
> >
> 
> 
> --
> Eric
> http://codehaus.org/~eredmond


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: HTTP compression (http://jira.codehaus.org/browse/WAGON-55)

Posted by Eric Redmond <er...@gmail.com>.
Hi Nathan;

It looks that the Jetty ResourceHandler will only return zipped content
ending in ".gz", so perhaps its a simple as hello.txt.gz?
(
http://www.dpml.net/api/jetty/5.1.6/org/mortbay/http/handler/ResourceHandler.html#setMinGzipLength(int)<http://www.dpml.net/api/jetty/5.1.6/org/mortbay/http/handler/ResourceHandler.html#setMinGzipLength%28int%29>)

Take care;
Eric

On 7/12/06, Nathan Beyer <nb...@kc.rr.com> wrote:
>
> I tried posting this to the WAGON mailing list, but there doesn't seem to
> be
> any activity over there...
>
> I've posted some attachments to the JIRA issue WAGON-55 [1] to implement
> support for accepting GZip-based compression with HTTP GETs for HTTP and
> WebDAV. I'm hoping these simple changes can help to reduce some bandwidth
> needs. I've seen some significant gains from my personal testing.
>
> In any case, a major barrier to getting these patches approved and applied
> is the lack of unit tests. I was able to test these patches myself using
> an
> Apache HTTPD server and mod_deflate, but couldn't quite figure out the
> best
> way to test in the JUnits. I tried setting up a Jetty embedded server and
> I
> was able to get a test to execute, but I couldn't get Jetty to compress
> the
> responses. Here's the test method I had so far trying to do this. If
> anyone
> knows how to get this compressing the response, please let me know. Also,
> any comments or suggestions on getting this test massaged to use the base
> classes embedded server would be appreciated as well.
>
>
>     public void testGzipGet()
>         throws Exception
>     {
>         HttpServer server = new HttpServer();
>         SocketListener listener = new SocketListener();
>         listener.setPort(10008);
>         server.addListener(listener);
>
>         HttpContext context = new HttpContext();
>         context.setContextPath("/");
>         context.setResourceBase("c:/temp/");
>         ResourceHandler rh = new ResourceHandler();
>           //The javadoc for these methods is confusing, does this compress
> the response?
>         rh.setMinGzipLength(1);
>         context.addHandler(rh);
>         server.addContext(context);
>         server.start();
>         try
>         {
>             HttpWagon wagon = new HttpWagon();
>             Repository repo = new Repository();
>             repo.setUrl("http://localhost:8080");
>             repo.setId("gzip-temp");
>             wagon.connect(repo);
>             wagon.get("hello.txt", new File("c:/temp/hello-copy.txt"));
>             wagon.disconnect();
>         }
>         finally
>         {
>             server.stop();
>         }
>     }
>
>
> Thanks,
> -Nathan Beyer
>
> [1] http://jira.codehaus.org/browse/WAGON-55 [Provide support for HTTP
> compression (request and response)]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>


-- 
Eric
http://codehaus.org/~eredmond