[Cosmo-dev] /home proxy in place

Jared Rhine jared at wordzoo.com
Sat Feb 24 19:54:17 PST 2007


I wrote and am now running the enclosed HTTP proxy on lab.osaf.us.
This, with the Apache-based routing of PROPFIND /cosmo/home URLs through
this proxy, has mitigated the issues with the failed osaf.us update last
week.

<insert snoopy dance here>

I've been able to run the "account dialog test" test case and the
"restore shares" test case.  I'm not asking for a specific additional
testing before scheduling another osaf.us update, but others are welcome
to test it out (against http://lab.osaf.us/cosmo) and report.  It'd of
course be wise to get more confirmations.  When I'm back in the office
Monday, I'll schedule the osaf.us update to Cosmo 0.6.0.

The new Apache rewrite set is:

  RewriteCond %{REQUEST_METHOD}  ^PROPFIND$
  RewriteRule ^/cosmo/home/(.*) http://localhost:10000/cosmo/dav/$1 [P,L]
  RewriteRule ^/cosmo/home/(.*) http://localhost:4001/cosmo/dav/$1 [P,L]
  RewriteRule ^/cosmo/(.*) http://localhost:4001/cosmo/$1 [P,L]

This approach should minimize any possible behavior changes.  Only
PROPFIND requests with a path of /cosmo/home are routed through the
"home-dav-proxy-perl" code below.

The "Apache module" approach wasn't getting very far quickly.
Compilation of the Webthing modules wasn't really documented, support
was sketchy ("send us money"), and they didn't seem to allow me to be
fine-grained enough (single method on single path).

If someone felt like schooling me in the Pythonic way to get the same
results, I'd happily learn.  I futzed with some Python/WSGI/scotch (the
code, not the drink) before just letting CPAN do the heavy lifting.

Note that requests through the above proxy get transformed into a
chunked content-encoding.  Chandler doesn't have any problem with that,
and neither do I.

-------- Forwarded Message --------

Added: osaf.us/bin/home-dav-proxy-perl (1477 => 1478)
--- osaf.us/bin/home-dav-proxy-perl	2007-02-23 20:25:48 UTC (rev 1477)
+++ osaf.us/bin/home-dav-proxy-perl	2007-02-25 03:44:51 UTC (rev 1478)
@@ -0,0 +1,32 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use HTTP::Proxy qw(NONE);
+use HTTP::Proxy::BodyFilter::simple;
+use HTTP::Proxy::HeaderFilter::simple;
+use Data::Dumper qw(Dumper);
+
+my $proxy_port = 10_000;
+my $orig_url = 'http://lab.osaf.us/cosmo/dav/';
+my $new_url  = 'http://lab.osaf.us/cosmo/home/';
+my $dest_server = 'http://localhost:4001/';
+
+my $request_filter = HTTP::Proxy::HeaderFilter::simple->new(
+   sub { shift->proxy->agent->proxy( http => $dest_server ) }
+);
+
+my $response_body = HTTP::Proxy::BodyFilter::simple->new(
+   sub { ${ $_[1] } =~ s/<D:href>$orig_url/<D:href>$new_url/g }
+);
+
+my $proxy = HTTP::Proxy->new;
+$proxy->port($proxy_port);
+$proxy->logmask(NONE);
+$proxy->push_filter(
+		    request => $request_filter,
+		    response => $response_body,
+		   );
+
+$proxy->start;
Property changes on: osaf.us/bin/home-dav-proxy-perl
___________________________________________________________________
Name: svn:executable
   + *

_______________________________________________
Commits-sandbox mailing list
Commits-sandbox at osafoundation.org
http://lists.osafoundation.org/mailman/listinfo/commits-sandbox



More information about the cosmo-dev mailing list