appetito / webdav-client-python-2

WebDAV Client - based on http://designerror.github.io/webdav-client-python, use requests instead of PyCURL
Other
1 stars 4 forks source link

Client should optionally take requests.Session object #10

Open aparamon opened 5 years ago

aparamon commented 5 years ago

Currently, Client creates a session per WebDAV request, e.g.: https://github.com/appetito/webdav-client-python-2/blob/a7da86be7c6a795287a2fd223666b3895def389a/webdav2/client.py#L159-L164 It is sub-optimal:

  1. HTTP connection is not re-used.
  2. It's not possible to use requests.Session with custom headers/transport adapters. It is proposed that Client can optionally be initialized with existing requests.Session instance.
herrAlison commented 8 months ago

import requests

with requests.session() as session:

url = 'https://register.fdsinstitut.com/ext/index.php'

headers = {} cookies = {} donnees = {}

reponse = session.post(url, headers=headers, cookies=cookies, data=donnees)

print(reponse.text)