Skip to content

Commit

Permalink
Fix Curl reuse bug
Browse files Browse the repository at this point in the history
  • Loading branch information
p committed Sep 21, 2016
1 parent f5ea1fb commit efdf681
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions python/curl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ def __request(self, relative_url=None):
if relative_url:
self.set_option(pycurl.URL, urljoin(self.base_url, relative_url))
self.payload = None
self.payload_io.seek(0)
self.payload_io.truncate()
self.hdr = ""
self.handle.perform()
self.payload = self.payload_io.getvalue()
Expand Down
25 changes: 25 additions & 0 deletions tests/high_level_curl_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vi:ts=4:et

# uses the high level interface
import curl
import unittest

from . import appmanager

setup_module, teardown_module = appmanager.setup(('app', 8380))

class RelativeUrlTest(unittest.TestCase):
def setUp(self):
self.curl = curl.Curl('http://localhost:8380/')

def tearDown(self):
self.curl.close()

def test_reuse(self):
result = self.curl.get('/success')
self.assertEqual('success', result)

result = self.curl.get('/success')
self.assertEqual('success', result)

0 comments on commit efdf681

Please sign in to comment.