Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

io.UnsupportedOperation: can't do nonzero cur-relative seeks #122

Open
dbergamin opened this issue Aug 4, 2020 · 2 comments
Open

io.UnsupportedOperation: can't do nonzero cur-relative seeks #122

dbergamin opened this issue Aug 4, 2020 · 2 comments

Comments

@dbergamin
Copy link

When doing PUT/POST this seems to run into an issue on Python 3 where streams are functioning slightly differently.

File "/home/db/development/test/lib/python3.8/site-packages/requests/sessions.py", line 512, in request
    resp = self.send(prep, **send_kwargs)
File "/home/db/development/test/lib/python3.8/site-packages/requests/sessions.py", line 629, in send
    r = dispatch_hook('response', hooks, r, **kwargs)
File "/home/db/development/test/lib/python3.8/site-packages/requests/hooks.py", line 31, in dispatch_hook
    _hook_data = hook(hook_data, **kwargs)
File "/home/db/development/pydev/mav_requests_ntlm/requests_ntlm.py", line 149, in response_hook
    return self.retry_using_http_NTLM_auth(
File "/home/db/development/pydev/mav_requests_ntlm/requests_ntlm.py", line 65, in retry_using_http_NTLM_auth
    response.request.body.seek(-content_length, 1)
io.UnsupportedOperation: can't do nonzero cur-relative seeks

Tested with 3.6 and 3.8, using requests_ntlm module to send a PUT or POST request:

        url = http://mysite.example.com/creatething"
        data = open('data.json')
        response = requests.put(url, headers=headers, data=data, auth=HttpNtlmAuth('DOMAIN\\" + self._username,self._password))
@dbergamin
Copy link
Author

At this point I don't fully understand the issue beyond what seems obvious. Wondering if would need to do something like https://2.python-requests.org/en/v3.0.0/_modules/requests/auth/ to record offset position at points in time, and then seek back to it. Would this be a viable option?

@dbergamin
Copy link
Author

For any others with the same issue, I could not find a simple workaround to get this going. I would suggest using https://github.com/pycurl/pycurl (for now) if you have a need to PUT/POST things to an NTLM authed endpoint using python 3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant