Menu

#194 HTTP transport proxy support patches

open
None
5
2007-01-22
2007-01-22
N-V
No

Hello Fred,

the attached files are a patched version of the latest stable (1.0.8_7) release and add limited proxy support to the http transport mechanism:

1. The database in web-server mode can be placed behind a web server and can be accessed on a virtual host. (E.g. apache with mod_proxy on a virtual host.)

2. The JDBC client can access the database server through an http proxy. The proxy - at present host and port only, no authentication - is configured on the jdbc connection string with extra parameters. Example:

jdbc:hsqldb:http[s]://<host>[:<port>]/<dbname>darts;httpproxyhost=<proxy host>;httpproxyport=<proxy port>

Limitations:

1. Client proxy autentication is not supported. (Can be added easily, though.)

2. Client https via proxy ssl tunneling is not supported. (This is a lot more tricky to add. Basically an additional handshake is needed that tells the proxy to tunnel ssl /CONNECT HTTP 1.1/. The resulting socket then must be re-used for the ssl socket. I couldn't see an easy way of fitting this into the existing structures.)

3. Web Server https support doesn't seem to work. (This might be just my inability of setting it up - it didn't work with the unpatched version of hsqldb either. Https in the jdbc client does work, however, I've tested it with apache set up for ssl and proxying over to hsqldb.) I'll do more testing on this.

I took a minimalistic approach, meaning that I tried to ring-fence the implementation and change theh code-base as little as possible. This is not the most elegant solution, but it represented the least risk in breaking anything else. Ultimately I would suggest that you consider using an out-of-the-box http client (like apache commons http client), which then deals with all the nitty-gritty of the http protocol, including proxies, redirects, authentication, etc. I couldn't see a trivial and safe/robust way of doing it and opted for these changes rather.

Ok, now the files:

1. org.hsqldb.HSQLClientConnection
Just added the proxy parameters. I would have liked to leave this class unchanged, but the way the login works (method called from the constructor/method overridden in descendant class) the proxy details have to be passed, otherwise they won't be available when write is called in HTTPClientConnection.

2. org.hsqldb.HTTPClientConnection
Added proxy handling in the constructor; made the request line virtual host and proxy-friendly by making the path a complete URL including protocol identifier, host, port, etc; and added HTTP 1.1 'Host:' header line to make the requst even more virtual host-firendly.

3. org.hsqldb.WebServerConnection
Removed header parsing from processing POST as it was unncessary (and marked as such). The order of header lines is not guaranteed and proxies can add any number of additional headers. Since it is a restricted HTTP server (expects requests from its own client only), it is ok to ignore the headers and go straight to the content. (Potential problem if the server changes encoding for example, but I'm yet to encounter such a problem.)

4. org.hsqldb.jdbc.jdbcConnection
Added handling of the proxy parameters

Let me know what you think,

Cheers,

Valentin

Discussion

  • N-V

    N-V - 2007-01-22

    Archive containing the patched files only.

     
  • N-V

    N-V - 2007-01-22
    • assigned_to: nobody --> fredt
     

Log in to post a comment.