Make sure we are only sending ascii characters in POST requests to avoid urllib2 encoding errors, and add the missed post var in the POST data
This commit is contained in:
parent
9e1a582826
commit
6c33c1eb24
|
@ -107,7 +107,9 @@ def downloadSpeed(files):
|
||||||
class FilePutter(threading.Thread):
|
class FilePutter(threading.Thread):
|
||||||
def __init__(self, url, start, size):
|
def __init__(self, url, start, size):
|
||||||
self.url = url
|
self.url = url
|
||||||
self.data = os.urandom(int(size)-len('content1='))
|
data = os.urandom(int(size)).encode('hex')
|
||||||
|
self.data = 'content1=%s' % data[0:int(size)-9]
|
||||||
|
del data
|
||||||
self.result = None
|
self.result = None
|
||||||
self.starttime = start
|
self.starttime = start
|
||||||
threading.Thread.__init__(self)
|
threading.Thread.__init__(self)
|
||||||
|
|
|
@ -25,6 +25,7 @@ import os
|
||||||
import sys
|
import sys
|
||||||
import hashlib
|
import hashlib
|
||||||
import threading
|
import threading
|
||||||
|
import binascii
|
||||||
from queue import Queue
|
from queue import Queue
|
||||||
|
|
||||||
|
|
||||||
|
@ -103,7 +104,9 @@ def downloadSpeed(files):
|
||||||
class FilePutter(threading.Thread):
|
class FilePutter(threading.Thread):
|
||||||
def __init__(self, url, start, size):
|
def __init__(self, url, start, size):
|
||||||
self.url = url
|
self.url = url
|
||||||
self.data = os.urandom(int(size)-len('content1='))
|
data = binascii.hexlify(os.urandom(int(size)-9)).decode()
|
||||||
|
self.data = 'content1=%s' % data[0:int(size)-9]
|
||||||
|
del data
|
||||||
self.result = None
|
self.result = None
|
||||||
self.starttime = start
|
self.starttime = start
|
||||||
threading.Thread.__init__(self)
|
threading.Thread.__init__(self)
|
||||||
|
@ -114,7 +117,7 @@ class FilePutter(threading.Thread):
|
||||||
def run(self):
|
def run(self):
|
||||||
try:
|
try:
|
||||||
if (time.time() - self.starttime) <= 10:
|
if (time.time() - self.starttime) <= 10:
|
||||||
f = urllib.request.urlopen(self.url, self.data)
|
f = urllib.request.urlopen(self.url, self.data.encode())
|
||||||
contents = f.read()
|
contents = f.read()
|
||||||
f.close()
|
f.close()
|
||||||
self.result = self.data
|
self.result = self.data
|
||||||
|
|
Loading…
Reference in New Issue