0

I am doing a HTTP DELETE with Python requests module, but I am facing a problem in my application because of the "Content-Length: 0". Is there a way to deal with this? Is possible to remove the "Content-Length: 0"? What do you suggest?

The problem is that the server application does not accept "Content-Length", neither payload. This way, my request should not have this information.

The request I am doing:

headers = {'X-Auth-Token': token}
r = requests.delete(DELETE_URL, headers=headers)
Dalton Cézane
  • 3,672
  • 2
  • 35
  • 60
  • 1
    Would you better explain the problem? Client side or server side? – wim Dec 27 '16 at 20:17
  • What's wrong with "Content-Length: 0"? – jwodder Dec 27 '16 at 21:13
  • @wim , I am doing a DELETE request to a server that does not accept content-length. So, I have to remove this information in my request. I am using this: r = requests.delete(DELETE_URL, headers=headers) #headers have just the x-auth-token header... Is there a more direct way to remove the "Content-Length" besides the example marked below as answer? – Dalton Cézane Dec 28 '16 at 19:05

1 Answers1

2

Well you can remove the header manually like in here

example:

from requests import Request, Session

s = Session()

req = Request('DELETE', url)
prepped = req.prepare()
del prepped.headers['Content-Length']
resp = s.send(prepped)
print(resp.status_code)
Corey Goldberg
  • 59,062
  • 28
  • 129
  • 143
DorElias
  • 2,243
  • 15
  • 18