/ dropstar / httpd.py
httpd
Handles all HTTP requests, GET only. It is intended to be READ only.
Use RPC for doing interaction with the backend, doing this inside a web
rendering request is a total pain in the ass and has all kinds of times
you'd like to have some feature you dont, and this isnt an end-user
oriented service, so is it assumed their JS will be working and can
submit any data we need them to. Code accordingly for best results.
When querying Cloud data from the Site Control API, we will always get the
cached version, so that web requests are fast. This is not the place we need
to wait on data.
NOTE(g): I left this a single threaded HTTP server because the requests should
be infrequent enough and fast enough that even "heavy" usage of this server
should not back up. It's an admin tool.
Functions
|
|
|
CGIArgsToDict
|
CGIArgsToDict ( args )
Convert our args string into a dictionary.
|
|
parse_multipart
|
parse_multipart ( fp, pdict )
Parse multipart input.
Arguments:
fp : input file
pdict: dictionary containing other parameters of content-type header
Returns a dictionary just like parse_qs(): keys are the field names, each
value is a list of values for that field. This is easy to use but not
much good if you are expecting megabytes to be uploaded -- in that case,
use the FieldStorage class instead which is much more flexible. Note
that content-type is the raw, unparsed contents of the content-type
header.
- XXX This does not parse nested multipart parts
- use FieldStorage for
that.
- XXX This should really be subsumed by FieldStorage altogether
- no
point in having two implementations of the same parsing algorithm.
Exceptions
|
|
ValueError, ('Invalid boundary in multipart form: %r' %( boundary, ) )
ValueError, 'Maximum content length exceeded'
|
|
|
UriParse
|
UriParse ( uri )
We want to parse the URI into a path and argument section. Return tuple.
Python's urlparse module fails on more complex data, such as sending Python
code across the line. It crops our data, breaking the submit, so we must do
this ourselves.
Args:
uri: string, uri (url, minus the protocol and host name)
Returns: tuple (path, args). Both strings.
|
|
|