Commit Graph

78 Commits

Author SHA1 Message Date
Brian Warner
9281a0aedc webish: reduce POST memory footprint by overriding http.Request
The original twisted.web.http.Request class has a requestReceived method
that parses the form body (in the request's .content filehandle) using
the stdlib cgi.parse_multipart() function. parse_multipart() consumes a
lot of memory when handling large file uploads, because it holds the
arguments entirely in RAM. Nevow's subclass of Request uses cgi.FieldStorage
instead, which is much more memory-efficient.

This patch uses a local subclass of Request and a modified copy of the
requestReceived method. It disables the cgi.parse_multipart parsing and
instead relies upon Nevow's use of FieldStorage. Our code must look for
form elements (which come from the body of the POST request) in req.fields,
rather than assuming that they will be copied into req.args (which now
only contains the query arguments that appear in the URL).

As a result, memory usage is no longer inflated by the size of the file
being uploaded in a POST upload request. Note that cgi.FieldStorage uses
temporary files (tempfile.TemporaryFile) to hold the data.

This closes #29.
2007-08-10 17:25:33 -07:00
Brian Warner
b6ff38e4c7 webish.POSTHandler: fix typo that meant we didn't look for 'name' in req.fields 2007-08-10 17:25:28 -07:00
Brian Warner
1d9a58977f uri: implement URI-processing classes, IFileURI/IDirnodeURI, use internally 2007-07-21 15:40:36 -07:00
Brian Warner
a7f04616bf webish: improve test coverage further 2007-07-17 12:28:29 -07:00
Brian Warner
3197e1d39b webish: improve test coverage of WebDownloadTarget 2007-07-17 12:16:45 -07:00
robk-org
920fed7f2a added unit test to webish's rename function
added unit tests to test various permutations of the rename function, and
some sanity checks on the rename-form function.

also added a guard to prevent '/' in from_/to_name in rename calls.
2007-07-16 17:05:01 -07:00
Brian Warner
56dcb814a8 webish: test error cases more thoroughly by looking inside the response text 2007-07-16 12:01:19 -07:00
Brian Warner
3f294d5597 webish: oops, handle POST without localfile= too 2007-07-16 12:00:54 -07:00
Brian Warner
f207f4a199 webish.py: disallow slashes in POSTed filenames. Closes #75. 2007-07-16 11:53:12 -07:00
Brian Warner
7bc031a81d webish.Directory: add a 'text/plain' link for files, to download as plaintext.
This is useful to view (e.g.) .py files that would otherwise be served as
some weird text/x-python that browsers will just want to save to disk.
2007-07-13 23:45:35 -07:00
Brian Warner
6e1ad64c9d webish.py: test that _get_or_create_directories fix I made a few hours ago 2007-07-13 22:19:16 -07:00
Brian Warner
a290205ade webish: handle PUTs to direct children of the root 2007-07-13 19:31:52 -07:00
robk-org
d65d02fa58 add a 'rename' button to the webish dir view
alongside the 'del' button is now presented a 'rename' button, which takes
the user to a new page, the 't=rename-form' page, which asks ther user for
the new name of the child and ultimately submits a POST request to the dir
for 't=rename' to perform the actual rename i.e. an attach followed by a
delete of children.
2007-07-12 16:53:54 -07:00
robk-org
15c3055176 fix bug in arg handling around 'delete' button in directory view
the code composing the form providing the 'delete' button in a dir
view was broken in that it tried to put some of the arguments into 
the url query, rather than as the form's post args.  worse, nevow
was kind enough to escape the querystring making it invalid.
2007-07-12 16:46:54 -07:00
robk-org
cacc9ac7b1 include the filename on URI-link urls for files
this is likely to induce browsers to do more useful things with the result
than they would when given neither content-type nor filename.  (i.e. they
can guess that a .jpg file is an image, even with a bogus content type)
2007-07-11 15:26:47 -07:00
Brian Warner
798b714bef webish.DirnodeWalkerMixin: comment out the code that demonstrates what we
would do if we could just use generators, since we don't use it.
2007-07-12 23:28:09 -07:00
Brian Warner
ba7e14a870 fix several methods to handle LIT URIs correctly, rather than assuming that all filenodes are CHK URIs 2007-07-12 16:17:49 -07:00
Brian Warner
ea3c3e6780 import simplejson directly, and remove our local copies of the component .py files from util/json* 2007-07-10 15:49:32 -07:00
Brian Warner
13e84526a1 webapi: normalized API: use t=upload or t=download when providing localdir= or localfile= 2007-07-10 13:24:10 -07:00
Brian Warner
5264559561 webish: cosmetic: fix missing whitespace in HTML 2007-07-10 10:33:19 -07:00
Brian Warner
0395ad76eb web: indent the JSON to make it easier for humans to read, but slightly larger 2007-07-08 00:23:23 -07:00
Brian Warner
72fc8c5cb8 web: use real JSON instead of the fake stubs
Also include the encoder portion of Bob Ippolito's simplejson-1.7.1 as
allmydata.util.json_encoder . simplejson is distributed under a more liberal
license than Tahoe (looks to be modified BSD), so redistributing it should be ok.
2007-07-08 00:17:11 -07:00
Brian Warner
bd8625076a web: remove t=XML, and other dead code 2007-07-07 22:55:15 -07:00
Brian Warner
159f8bfd50 web: improve test coverage 2007-07-07 22:47:18 -07:00
Brian Warner
135f08a518 web: remove more dead code 2007-07-07 22:20:03 -07:00
Brian Warner
8952114442 webish.py: remove dead code 2007-07-07 22:12:46 -07:00
Brian Warner
62e8528cc6 web: /uri/ must escape slashes, we use bangs for this 2007-07-07 22:06:52 -07:00
Brian Warner
fb40b55bc3 web: replace welcome-page download-URI form with new version 2007-07-07 22:06:22 -07:00
Brian Warner
5b0c9df14c web: survive bogus URIs when displaying sizes 2007-07-07 21:31:18 -07:00
Brian Warner
fe3c002842 web: show the root name of the vdrive 2007-07-07 21:31:02 -07:00
Brian Warner
e5482b5254 web: add a 'return to welcome page' link 2007-07-07 21:30:04 -07:00
Brian Warner
2adb773210 web: add when_done to all POST operations, use it from upload/mkdir/mount/delete forms 2007-07-07 21:17:48 -07:00
Brian Warner
0cb154f402 web: make 'delete' buttons work again 2007-07-07 20:46:30 -07:00
Brian Warner
b3f0293d50 web: change per-directory forms to match new POST scheme 2007-07-07 20:35:47 -07:00
Brian Warner
617a85df67 web: remove debug prints 2007-07-07 20:11:30 -07:00
Brian Warner
464f25e5f2 web: more test work, now all tests pass, POST too, only XMLRPC left to implement 2007-07-07 20:06:58 -07:00
Brian Warner
7d92b8a123 webish.py: add links to JSON/etc representations of directory contents to the listing 2007-07-07 11:31:07 -07:00
Brian Warner
10a5ff3767 webish: fix ?t=manifest, ?t=xml so they don't throw exceptions, prune directory.xhtml 2007-07-07 11:15:31 -07:00
Brian Warner
0cd730a7b3 web: more test work, now all tests either pass or are skipped (POST, XMLRPC, and URI/) 2007-07-07 10:34:05 -07:00
Brian Warner
d501984eba webapi: checkpointing more test progress 2007-07-07 00:16:36 -07:00
Brian Warner
6570253d6b checkpointing new webapi: not all tests pass yet 2007-07-06 19:43:55 -07:00
Brian Warner
c4a8db3eb2 webish: provide a valid Content-Length header on downloads 2007-07-03 15:09:00 -07:00
Brian Warner
622acc690a webish: improve reporting of web download errors that occur early enough
If the error occurs before any data has been sent, we can give a sensible
error message (code 500, stack trace, etc). This will cover most of the error
cases. The ones that aren't covered are when we run out of good peers after
successfully decoding the first segment, either because they go away or
because their shares are corrupt.
2007-07-03 13:47:37 -07:00
Brian Warner
f15bb302a1 webish.py: handle errors during download better. Addresses #65.
Previously, exceptions during a web download caused a hang rather than some
kind of exception or error message. This patch improves the situation by
terminating the HTTP download rather than letting it hang forever. The
behavior still isn't ideal, however, because the error can occur too late to
abort the HTTP request cleanly (i.e. with an error code). In fact, the
Content-Type header and response code have already been set by the time any
download errors have been detected, so the browser is committed to displaying
an image or whatever (thus any error message we put into the stream is
unlikely to be displayed in a meaningful way).
2007-07-03 13:18:14 -07:00
Brian Warner
6427b44b42 webish: make each link in the directory name an href to that directory 2007-06-29 11:17:18 -07:00
Brian Warner
9ecde0d23e webish: fix link to private_vdrive 2007-06-28 19:07:52 -07:00
Brian Warner
b06c74c2a1 Add the 'vdrive' service, for clients to access the public/private root dirs.
These allow client-side code to conveniently retrieve the IDirectoryNode
instances for both the global shared public root directory, and the per-user
private root directory.
2007-06-27 17:11:06 -07:00
Brian Warner
1d86cd161b webish.py: add a web page to display the manifest for any particular directory 2007-06-26 19:55:21 -07:00
Brian Warner
b11fa20191 merge vdrive.py and filetable.py into a single dirnode.py 2007-06-26 17:16:58 -07:00
Brian Warner
b6162681d5 webish: mark read-only directories as such when listing their parent 2007-06-26 12:37:00 -07:00