0

I am trying to make a post request using pycurl but request hangs infinitely on c.perform(). My code is:

    try:
        from io import BytesIO
    except ImportError:
        from io import StringIO as BytesIO

    buffer = BytesIO()
    self.c.setopt(self.c.URL, 'http://pycurl.io/')
    self.c.setopt(self.c.HEADER, 0)
    self.c.setopt(self.c.POST, 1)
    self.c.perform()
    self.c.close()
    body = buffer.getvalue()

    status = self.c.getinfo(self.c.HTTP_CODE)
    response_data = {
        'is_fed_successfully': True
    }'

And just to be clear, there's no error. The request just hangs infinitely without any response.

john doe
  • 65
  • 2
  • 9

1 Answers1

2

I had this problem too. What worked for me was to pass some empty data using POSTFIELDS. You could try adding this line.

self.c.setopt(self.c.POSTFIELDS,'')

I'm guessing it is hanging because it is waiting for data that never comes.