mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-06-06 09:31:43 +00:00
command-line: fix ticket #111 by requiring input to be a local file and sending Content-Length header
This commit is contained in:
parent
594912e334
commit
9996836d23
@ -45,8 +45,8 @@ class PutOptions(VDriveOptions):
|
|||||||
return "%s put LOCAL_FILE VDRIVE_FILE" % (os.path.basename(sys.argv[0]),)
|
return "%s put LOCAL_FILE VDRIVE_FILE" % (os.path.basename(sys.argv[0]),)
|
||||||
|
|
||||||
longdesc = """Put a file into the virtual drive (copying the file's
|
longdesc = """Put a file into the virtual drive (copying the file's
|
||||||
contents from the local filesystem). If LOCAL_FILE is omitted or '-', the
|
contents from the local filesystem). LOCAL_FILE is required to be a
|
||||||
contents of the file will be read from stdin."""
|
local file (it can't be stdin)."""
|
||||||
|
|
||||||
class RmOptions(VDriveOptions):
|
class RmOptions(VDriveOptions):
|
||||||
def parseArgs(self, vdrive_pathname):
|
def parseArgs(self, vdrive_pathname):
|
||||||
|
@ -18,16 +18,16 @@ def put(nodeurl, vdrive, local_fname, vdrive_fname, verbosity):
|
|||||||
if vdrive_fname:
|
if vdrive_fname:
|
||||||
url += vdrive_fname
|
url += vdrive_fname
|
||||||
|
|
||||||
if local_fname is None or local_fname == "-":
|
infileobj = open(local_fname, "rb")
|
||||||
infileobj = sys.stdin
|
infileobj.seek(0, 2)
|
||||||
else:
|
infilelen = infileobj.tell()
|
||||||
infileobj = open(local_fname, "rb")
|
infileobj.seek(0, 0)
|
||||||
|
|
||||||
so = socket.socket()
|
so = socket.socket()
|
||||||
so.connect((host, port,))
|
so.connect((host, port,))
|
||||||
|
|
||||||
CHUNKSIZE=2**16
|
CHUNKSIZE=2**16
|
||||||
data = "PUT %s HTTP/1.1\r\nConnection: close\r\nHostname: %s\r\n\r\n" % (url, host,)
|
data = "PUT %s HTTP/1.1\r\nConnection: close\r\nContent-Length: %s\r\nHostname: %s\r\n\r\n" % (url, infilelen, host,)
|
||||||
while data:
|
while data:
|
||||||
try:
|
try:
|
||||||
sent = so.send(data)
|
sent = so.send(data)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user