diff options
| author | P. Christeas <p_christ@hol.gr> | 2010-07-26 12:33:35 +0300 |
|---|---|---|
| committer | P. Christeas <p_christ@hol.gr> | 2010-07-26 12:33:35 +0300 |
| commit | 4e36352f5ebb7a2bbdddd3a249cc5b2f4a428a96 (patch) | |
| tree | 916ccf3123a02a2edbf638bdc8750a3d01e050cf /bin/service | |
| parent | 59efa51612d8f85fab2ad503080b353fe4930bde (diff) | |
Http server: support the OPTIONS at the multi-handler.
Now, fixes nautilus trying to browse the server for WebDAV, conforms to
the http standard.
Handlers should better inherit the HttpOptions class and define their
supported options.
bzr revid: p_christ@hol.gr-20100726093335-xzkqw60uyy87mcnq
Diffstat (limited to 'bin/service')
| -rw-r--r-- | bin/service/websrv_lib.py | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/bin/service/websrv_lib.py b/bin/service/websrv_lib.py index b0dd0aa8d21..0022fe6daf4 100644 --- a/bin/service/websrv_lib.py +++ b/bin/service/websrv_lib.py @@ -175,7 +175,19 @@ class FixSendError: if self.command != 'HEAD' and code >= 200 and code not in (204, 304): self.wfile.write(content) -class MultiHTTPHandler(FixSendError,BaseHTTPRequestHandler): +class HttpOptions: + _HTTP_OPTIONS = 'OPTIONS' + + def do_OPTIONS(self): + """return the list of capabilities """ + + self.send_response(200) + self.send_header("Content-Length", 0) + + self.send_header('Allow', self._HTTP_OPTIONS) + self.end_headers() + +class MultiHTTPHandler(FixSendError, HttpOptions, BaseHTTPRequestHandler): """ this is a multiple handler, that will dispatch each request to a nested handler, iff it matches @@ -229,6 +241,9 @@ class MultiHTTPHandler(FixSendError,BaseHTTPRequestHandler): return mname = 'do_' + fore.command if not hasattr(fore, mname): + if fore.command == 'OPTIONS': + self.do_OPTIONS() + return self.send_error(501, "Unsupported method (%r)" % fore.command) return fore.close_connection = 0 @@ -332,6 +347,14 @@ class MultiHTTPHandler(FixSendError,BaseHTTPRequestHandler): self.log_message("Could not parse rawline.") return # self.parse_request(): # Do NOT parse here. the first line should be the only + + if self.path == '*' and self.command == 'OPTIONS': + # special handling of path='*', must not use any vdir at all. + if not self.parse_request(): + return + self.do_OPTIONS() + return + for vdir in self.server.vdirs: p = vdir.matches(self.path) if p == False: |
