pypath icon indicating copy to clipboard operation
pypath copied to clipboard

```_req_headers_list``` in curl module doesn't work as intended

Open MelihDarcanxyz opened this issue 3 years ago • 3 comments

Describe the bug I can't send authorizaton or any kind of headers to websites with curl module in pypath if the headers are defined as dictionary.

To Reproduce Steps to reproduce the behavior:

  1. Define headers as dictionary
  2. Transmit them, for example use them to authorize in an API.

Expected behavior I wanted it (_req_headers_list) to turn dictionary headers to list objects.

Traceback I don't have a traceback but I see that no headers are transmitted. If I turn them into list object everything works fine. After the initial connection, it doesn't matter at all since curl is using cached data. The problem lies within the _req_headers_list module. I suspect the self.req_headers = self.req_headers or [] line but I'm not quite sure since it looks logically okay.

Desktop (please complete the following information):

  • OS: Linux 5.15.54-1-lts x86_64
  • Python version: Python 3.10.5

MelihDarcanxyz avatar Jul 21 '22 06:07 MelihDarcanxyz

Just tried the function on a jupyter notebook and it worked as it should. I'm not sure whether it's a problem about Curl class or me problem. Curl class still can't understand dictionary headers though.

MelihDarcanxyz avatar Jul 21 '22 07:07 MelihDarcanxyz

Reading the code it seems to me both lists or dicts should work fine, i.e. the headers can be passed either as ["Accept-encoding: gzip, deflate"] or {"Accept-encoding": "gzip, deflate"}. If you have different experience, please send a specific example.

deeenes avatar Nov 30 '22 12:11 deeenes

Well, the latter just didn't work at the time while the former worked quite wells. I read the code too but couldn't figure out why. Will try it when I can.

MelihDarcanxyz avatar Nov 30 '22 14:11 MelihDarcanxyz