tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

upload.py (788B)


      1 from wptserve.utils import isomorphic_encode
      2 
      3 def main(request, response):
      4    content = []
      5 
      6    for key, values in sorted(item for item in request.POST.items() if not hasattr(item[1][0], u"filename")):
      7        content.append(b"%s=%s," % (key, values[0]))
      8    content.append(b"\n")
      9 
     10    for key, values in sorted(item for item in request.POST.items() if hasattr(item[1][0], u"filename")):
     11        value = values[0]
     12        content.append(b"%s=%s:%s:%d," % (key,
     13                                          isomorphic_encode(value.filename),
     14                                          isomorphic_encode(value.headers[u"Content-Type"]) if value.headers[u"Content-Type"] is not None else b"None",
     15                                          len(value.file.read())))
     16 
     17    return b"".join(content)