{"action":"opened","issue":{"url":"https://api.github.com/repos/quantmind/pulsar/issues/312","repository_url":"https://api.github.com/repos/quantmind/pulsar","labels_url":"https://api.github.com/repos/quantmind/pulsar/issues/312/labels{/name}","comments_url":"https://api.github.com/repos/quantmind/pulsar/issues/312/comments","events_url":"https://api.github.com/repos/quantmind/pulsar/issues/312/events","html_url":"https://github.com/quantmind/pulsar/issues/312","id":349249860,"node_id":"MDU6SXNzdWUzNDkyNDk4NjA=","number":312,"title":"file upload doesn't work in combination with DigestAuth","user":{"login":"DavHau","id":42246742,"node_id":"MDQ6VXNlcjQyMjQ2NzQy","avatar_url":"https://avatars0.githubusercontent.com/u/42246742?v=4","gravatar_id":"","url":"https://api.github.com/users/DavHau","html_url":"https://github.com/DavHau","followers_url":"https://api.github.com/users/DavHau/followers","following_url":"https://api.github.com/users/DavHau/following{/other_user}","gists_url":"https://api.github.com/users/DavHau/gists{/gist_id}","starred_url":"https://api.github.com/users/DavHau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DavHau/subscriptions","organizations_url":"https://api.github.com/users/DavHau/orgs","repos_url":"https://api.github.com/users/DavHau/repos","events_url":"https://api.github.com/users/DavHau/events{/privacy}","received_events_url":"https://api.github.com/users/DavHau/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-08-09T18:58:53Z","updated_at":"2018-08-09T18:58:53Z","closed_at":null,"author_association":"NONE","body":"* **pulsar version**:\r\n2.0.2\r\n* **python version**:\r\n3.6.5\r\n* **platform**:\r\nLinux/Ubuntu16.04\r\n\r\n## Description\r\nwhen posting a file while using DigestAuth as authentication method, an empty file is uploaded instead\r\n\r\n## Expected behaviour\r\nThe file should be uploaded with its correct content\r\n\r\n## Actual behaviour\r\nA file with no content is uploaded\r\n\r\n## Steps to reproduce\r\nFlaskDigestAuthServer.py\r\n```\r\nfrom flask import Flask, flash, request, redirect\r\nfrom flask_httpauth import HTTPDigestAuth\r\n\r\napp = Flask(__name__)\r\napp.config['SECRET_KEY'] = 'secret key here'\r\nauth = HTTPDigestAuth()\r\nusers = {\r\n    \"root\": \"root\",\r\n}\r\n\r\n@auth.get_password\r\ndef get_pw(username):\r\n    if username in users:\r\n        return users.get(username)\r\n    return None\r\n\r\n@app.route('/', methods=['GET', 'POST'])\r\n@auth.login_required\r\ndef upload_file():\r\n    if request.method == 'POST':\r\n        # check if the post request has the file part\r\n        if 'file' not in request.files:\r\n            flash('No file part')\r\n            return redirect(request.url)\r\n        file = request.files['file']\r\n        fileContent = file.read().decode()\r\n        if fileContent == '':\r\n            return 'file was empty'\r\n        else:\r\n            return fileContent\r\n    return '''\r\n    <!doctype html>\r\n    <title>Upload new File</title>\r\n    <h1>Upload new File</h1>\r\n    <form method=post enctype=multipart/form-data>\r\n      <input type=file name=file>\r\n      <input type=submit value=Upload>\r\n    </form>\r\n    '''\r\n\r\nif __name__ == '__main__':\r\n    app.run(port=1337)\r\n```\r\n\r\nTestFileUpload.py\r\n```\r\nfrom pulsar.apps import http\r\nfrom tempfile import NamedTemporaryFile\r\nimport asyncio\r\n\r\nasync def request():\r\n  with NamedTemporaryFile() as tmpFile:\r\n    tmpFile.write('hello world'.encode())\r\n    tmpFile.seek(0)\r\n    sessions = http.HttpClient()\r\n    resp = await sessions.post(\r\n\t\t    'http://127.0.0.1:1337/',\r\n\t\t    files={'file': tmpFile},\r\n\t\t    auth=http.HTTPDigestAuth('root', 'root')\r\n    )\r\n    print(resp.text)\r\n\r\nasyncio.get_event_loop().run_until_complete(request())\r\n```\r\n\r\nThe server responds with 'file was empty' even the file had the content 'hello world'\r\nAs soon as one comments out the '@auth.login_required' from the server and the 'auth=http.HTTPDigestAuth('root', 'root')' of the client, the file content is returned correctly\r\nThis is not an issue of Flask. I noticed this this bug while trying to upload a file to some digestAuth enabled lighttpd server"}}
{"actor":{"display_login":"DavHau"}}