Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ omit =
*/python?.?/*
*/site-packages/*
*/pypy/*
*kombu/async/http/curl.py
*kombu/async/http/urllib3_client.py
*kombu/five.py
*kombu/transport/mongodb.py
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
python-version: ["3.13"]
steps:
- name: Install system packages
run: sudo apt-get update && sudo apt-get install libssl-dev
run: sudo apt-get update && sudo apt-get install libcurl4-openssl-dev libssl-dev
- name: Check out code from GitHub
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
steps:
- name: Install apt packages
if: startsWith(matrix.os, 'blacksmith-4vcpu-ubuntu')
run: sudo apt-get update && sudo apt-get install libssl-dev
run: sudo apt-get update && sudo apt-get install libcurl4-openssl-dev libssl-dev
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: useblacksmith/setup-python@v6
Expand Down Expand Up @@ -98,7 +98,7 @@ jobs:

steps:
- name: Install apt packages
run: sudo apt-get update && sudo apt-get install libssl-dev
run: sudo apt-get update && sudo apt-get install libcurl4-openssl-dev libssl-dev

- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
Expand Down
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ Ollie Walsh <ollie.walsh@geemail.kom>
Pascal Hartig <phartig@rdrei.net>
Patrick Schneider <patrick.p2k.schneider@gmail.com>
Paul McLanahan <paul@mclanahan.net>
Paul Rysiavets <paul@covadem.com>
Petar Radosevic <petar@wunki.org>
Peter Hoffmann <tosh54@gmail.com>
Pierre Riteau <priteau@ci.uchicago.edu>
Expand Down
1 change: 1 addition & 0 deletions docs/reference/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ Kombu Asynchronous
kombu.asynchronous.debug
kombu.asynchronous.http
kombu.asynchronous.http.base
kombu.asynchronous.http.curl
kombu.asynchronous.http.urllib3_client
kombu.asynchronous.aws
kombu.asynchronous.aws.connection
Expand Down
4 changes: 4 additions & 0 deletions kombu/asynchronous/http/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

def Client(hub: Hub | None = None, **kwargs: int) -> BaseClient:
"""Create new HTTP client."""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will this work as expected? we are not using any try except block here, I'm open to better suggestions as well

Copy link
Contributor Author

@spawn-guy spawn-guy Mar 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i've looked at try-catch, but liner was complaining. and.. the .curl code already has this ImportError exception handling. so until the CurlClient is instantiated - there will be no exception. however the CurlClient.Curl will be None.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ima gonna test the code now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the code seems to work without pycurl and no thrown Exceptions

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

from .curl import CurlClient
if CurlClient.Curl is not None:
return CurlClient(hub, **kwargs)

Check warning on line 14 in kombu/asynchronous/http/__init__.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/__init__.py#L14

Added line #L14 was not covered by tests

from .urllib3_client import Urllib3Client
return Urllib3Client(hub, **kwargs)

Expand Down
294 changes: 294 additions & 0 deletions kombu/asynchronous/http/curl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,294 @@
"""HTTP Client using pyCurl."""

from __future__ import annotations

from collections import deque
from functools import partial
from io import BytesIO
from time import time

from kombu.asynchronous.hub import READ, WRITE, Hub, get_event_loop
from kombu.exceptions import HttpError
from kombu.utils.encoding import bytes_to_str

from .base import BaseClient

try:
import pycurl
except ImportError: # pragma: no cover
pycurl = Curl = METH_TO_CURL = None
else:
from pycurl import Curl

Check warning on line 21 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L21

Added line #L21 was not covered by tests

METH_TO_CURL = {

Check warning on line 23 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L23

Added line #L23 was not covered by tests
'GET': pycurl.HTTPGET,
'POST': pycurl.POST,
'PUT': pycurl.UPLOAD,
'HEAD': pycurl.NOBODY,
}

__all__ = ('CurlClient',)

DEFAULT_USER_AGENT = 'Mozilla/5.0 (compatible; pycurl)'
EXTRA_METHODS = frozenset(['DELETE', 'OPTIONS', 'PATCH'])


class CurlClient(BaseClient):
"""Curl HTTP Client."""

Curl = Curl

def __init__(self, hub: Hub | None = None, max_clients: int = 10):
if pycurl is None:
raise ImportError('The curl client requires the pycurl library.')
hub = hub or get_event_loop()
super().__init__(hub)
self.max_clients = max_clients

Check warning on line 46 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L43-L46

Added lines #L43 - L46 were not covered by tests

self._multi = pycurl.CurlMulti()
self._multi.setopt(pycurl.M_TIMERFUNCTION, self._set_timeout)
self._multi.setopt(pycurl.M_SOCKETFUNCTION, self._handle_socket)

Check warning on line 50 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L48-L50

Added lines #L48 - L50 were not covered by tests
self._curls = [self.Curl() for i in range(max_clients)]
self._free_list = self._curls[:]
self._pending = deque()
self._fds = {}

Check warning on line 54 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L52-L54

Added lines #L52 - L54 were not covered by tests

self._socket_action = self._multi.socket_action
self._timeout_check_tref = self.hub.call_repeatedly(

Check warning on line 57 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L56-L57

Added lines #L56 - L57 were not covered by tests
1.0, self._timeout_check,
)

# pycurl 7.29.0 workaround
dummy_curl_handle = pycurl.Curl()
self._multi.add_handle(dummy_curl_handle)
self._multi.remove_handle(dummy_curl_handle)

Check warning on line 64 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L62-L64

Added lines #L62 - L64 were not covered by tests

def close(self):
self._timeout_check_tref.cancel()

Check warning on line 67 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L67

Added line #L67 was not covered by tests
for _curl in self._curls:
_curl.close()
self._multi.close()

Check warning on line 70 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L69-L70

Added lines #L69 - L70 were not covered by tests

def add_request(self, request):
self._pending.append(request)
self._process_queue()
self._set_timeout(0)
return request

Check warning on line 76 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L73-L76

Added lines #L73 - L76 were not covered by tests

# the next two methods are used for linux/epoll workaround:
# we temporarily remove all curl fds from hub, so curl cannot
# close a fd which is still inside epoll
def _pop_from_hub(self):
for fd in self._fds:
self.hub.remove(fd)

Check warning on line 83 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L83

Added line #L83 was not covered by tests

def _push_to_hub(self):
for fd, events in self._fds.items():
if events & READ:
self.hub.add_reader(fd, self.on_readable, fd)

Check warning on line 88 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L88

Added line #L88 was not covered by tests
if events & WRITE:
self.hub.add_writer(fd, self.on_writable, fd)

Check warning on line 90 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L90

Added line #L90 was not covered by tests

def _handle_socket(self, event, fd, multi, data, _pycurl=pycurl):
if event == _pycurl.POLL_REMOVE:
if fd in self._fds:
self._fds.pop(fd, None)

Check warning on line 95 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L95

Added line #L95 was not covered by tests
else:
if event == _pycurl.POLL_IN:
self._fds[fd] = READ

Check warning on line 98 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L98

Added line #L98 was not covered by tests
elif event == _pycurl.POLL_OUT:
self._fds[fd] = WRITE

Check warning on line 100 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L100

Added line #L100 was not covered by tests
elif event == _pycurl.POLL_INOUT:
self._fds[fd] = READ | WRITE

Check warning on line 102 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L102

Added line #L102 was not covered by tests

def _set_timeout(self, msecs):
self.hub.call_later(msecs, self._timeout_check)

Check warning on line 105 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L105

Added line #L105 was not covered by tests

def _timeout_check(self, _pycurl=pycurl):
self._pop_from_hub()
try:
while 1:
try:
ret, _ = self._multi.socket_all()
except pycurl.error as exc:
ret = exc.args[0]

Check warning on line 114 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L108-L114

Added lines #L108 - L114 were not covered by tests
if ret != _pycurl.E_CALL_MULTI_PERFORM:
break

Check warning on line 116 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L116

Added line #L116 was not covered by tests
finally:
self._push_to_hub()
self._process_pending_requests()

Check warning on line 119 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L118-L119

Added lines #L118 - L119 were not covered by tests

def on_readable(self, fd, _pycurl=pycurl):
return self._on_event(fd, _pycurl.CSELECT_IN)

Check warning on line 122 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L122

Added line #L122 was not covered by tests

def on_writable(self, fd, _pycurl=pycurl):
return self._on_event(fd, _pycurl.CSELECT_OUT)

Check warning on line 125 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L125

Added line #L125 was not covered by tests

def _on_event(self, fd, event, _pycurl=pycurl):
self._pop_from_hub()
try:
while 1:
try:
ret, _ = self._socket_action(fd, event)
except pycurl.error as exc:
ret = exc.args[0]

Check warning on line 134 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L128-L134

Added lines #L128 - L134 were not covered by tests
if ret != _pycurl.E_CALL_MULTI_PERFORM:
break

Check warning on line 136 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L136

Added line #L136 was not covered by tests
finally:
self._push_to_hub()
self._process_pending_requests()

Check warning on line 139 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L138-L139

Added lines #L138 - L139 were not covered by tests

def _process_pending_requests(self):
while 1:
q, succeeded, failed = self._multi.info_read()

Check warning on line 143 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L142-L143

Added lines #L142 - L143 were not covered by tests
for curl in succeeded:
self._process(curl)

Check warning on line 145 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L145

Added line #L145 was not covered by tests
for curl, errno, reason in failed:
self._process(curl, errno, reason)

Check warning on line 147 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L147

Added line #L147 was not covered by tests
if q == 0:
break
self._process_queue()

Check warning on line 150 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L149-L150

Added lines #L149 - L150 were not covered by tests

def _process_queue(self):
while 1:
started = 0

Check warning on line 154 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L153-L154

Added lines #L153 - L154 were not covered by tests
while self._free_list and self._pending:
started += 1
curl = self._free_list.pop()
request = self._pending.popleft()
headers = self.Headers()
buf = BytesIO()
curl.info = {

Check warning on line 161 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L156-L161

Added lines #L156 - L161 were not covered by tests
'headers': headers,
'buffer': buf,
'request': request,
'curl_start_time': time(),
}
self._setup_request(curl, request, buf, headers)
self._multi.add_handle(curl)

Check warning on line 168 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L167-L168

Added lines #L167 - L168 were not covered by tests
if not started:
break

Check warning on line 170 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L170

Added line #L170 was not covered by tests

def _process(self, curl, errno=None, reason=None, _pycurl=pycurl):
info, curl.info = curl.info, None
self._multi.remove_handle(curl)
self._free_list.append(curl)
buffer = info['buffer']

Check warning on line 176 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L173-L176

Added lines #L173 - L176 were not covered by tests
if errno:
code = 599
error = HttpError(code, reason)
error.errno = errno
effective_url = None
buffer.close()
buffer = None

Check warning on line 183 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L178-L183

Added lines #L178 - L183 were not covered by tests
else:
error = None
code = curl.getinfo(_pycurl.HTTP_CODE)
effective_url = curl.getinfo(_pycurl.EFFECTIVE_URL)
buffer.seek(0)

Check warning on line 188 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L185-L188

Added lines #L185 - L188 were not covered by tests
# try:
request = info['request']
request.on_ready(self.Response(

Check warning on line 191 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L190-L191

Added lines #L190 - L191 were not covered by tests
request=request, code=code, headers=info['headers'],
buffer=buffer, effective_url=effective_url, error=error,
))

def _setup_request(self, curl, request, buffer, headers, _pycurl=pycurl):
setopt = curl.setopt
setopt(_pycurl.URL, bytes_to_str(request.url))

Check warning on line 198 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L197-L198

Added lines #L197 - L198 were not covered by tests

# see tornado curl client
request.headers.setdefault('Expect', '')
request.headers.setdefault('Pragma', '')

Check warning on line 202 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L201-L202

Added lines #L201 - L202 were not covered by tests

setopt(
_pycurl.HTTPHEADER,
['{}: {}'.format(*h) for h in request.headers.items()],
)

setopt(

Check warning on line 209 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L209

Added line #L209 was not covered by tests
_pycurl.HEADERFUNCTION,
partial(request.on_header or self.on_header, request.headers),
)
setopt(

Check warning on line 213 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L213

Added line #L213 was not covered by tests
_pycurl.WRITEFUNCTION, request.on_stream or buffer.write,
)
setopt(

Check warning on line 216 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L216

Added line #L216 was not covered by tests
_pycurl.FOLLOWLOCATION, request.follow_redirects,
)
setopt(

Check warning on line 219 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L219

Added line #L219 was not covered by tests
_pycurl.USERAGENT,
bytes_to_str(request.user_agent or DEFAULT_USER_AGENT),
)
if request.network_interface:
setopt(_pycurl.INTERFACE, request.network_interface)
setopt(

Check warning on line 225 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L224-L225

Added lines #L224 - L225 were not covered by tests
_pycurl.ENCODING, 'gzip,deflate' if request.use_gzip else 'none',
)
if request.proxy_host:
if not request.proxy_port:
raise ValueError('Request with proxy_host but no proxy_port')
setopt(_pycurl.PROXY, request.proxy_host)
setopt(_pycurl.PROXYPORT, request.proxy_port)

Check warning on line 232 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L230-L232

Added lines #L230 - L232 were not covered by tests
if request.proxy_username:
setopt(_pycurl.PROXYUSERPWD, '{}:{}'.format(

Check warning on line 234 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L234

Added line #L234 was not covered by tests
request.proxy_username, request.proxy_password or ''))

setopt(_pycurl.SSL_VERIFYPEER, 1 if request.validate_cert else 0)
setopt(_pycurl.SSL_VERIFYHOST, 2 if request.validate_cert else 0)

Check warning on line 238 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L237-L238

Added lines #L237 - L238 were not covered by tests
if request.ca_certs is not None:
setopt(_pycurl.CAINFO, request.ca_certs)

Check warning on line 240 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L240

Added line #L240 was not covered by tests

setopt(_pycurl.IPRESOLVE, pycurl.IPRESOLVE_WHATEVER)

Check warning on line 242 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L242

Added line #L242 was not covered by tests

for meth in METH_TO_CURL.values():
setopt(meth, False)
try:
meth = METH_TO_CURL[request.method]
except KeyError:
curl.setopt(_pycurl.CUSTOMREQUEST, request.method)

Check warning on line 249 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L245-L249

Added lines #L245 - L249 were not covered by tests
else:
curl.unsetopt(_pycurl.CUSTOMREQUEST)
setopt(meth, True)

Check warning on line 252 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L251-L252

Added lines #L251 - L252 were not covered by tests

if request.method in ('POST', 'PUT'):
if not request.body:
body = b''

Check warning on line 256 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L256

Added line #L256 was not covered by tests
else:
body = request.body if isinstance(request.body, bytes) else request.body.encode('utf-8')

Check warning on line 258 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L258

Added line #L258 was not covered by tests

reqbuffer = BytesIO(body)
setopt(_pycurl.READFUNCTION, reqbuffer.read)

Check warning on line 261 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L260-L261

Added lines #L260 - L261 were not covered by tests
if request.method == 'POST':

def ioctl(cmd):

Check warning on line 264 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L264

Added line #L264 was not covered by tests
if cmd == _pycurl.IOCMD_RESTARTREAD:
reqbuffer.seek(0)

Check warning on line 266 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L266

Added line #L266 was not covered by tests

setopt(_pycurl.IOCTLFUNCTION, ioctl)
setopt(_pycurl.POSTFIELDSIZE, len(body))

Check warning on line 269 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L268-L269

Added lines #L268 - L269 were not covered by tests
else:
setopt(_pycurl.INFILESIZE, len(body))

Check warning on line 271 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L271

Added line #L271 was not covered by tests
elif request.method == 'GET':
assert not request.body

Check warning on line 273 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L273

Added line #L273 was not covered by tests

if request.auth_username is not None:
auth_mode = {

Check warning on line 276 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L276

Added line #L276 was not covered by tests
'basic': _pycurl.HTTPAUTH_BASIC,
'digest': _pycurl.HTTPAUTH_DIGEST
}[request.auth_mode or 'basic']
setopt(_pycurl.HTTPAUTH, auth_mode)
userpwd = '{}:{}'.format(

Check warning on line 281 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L280-L281

Added lines #L280 - L281 were not covered by tests
request.auth_username, request.auth_password or '',
)
setopt(_pycurl.USERPWD, userpwd)

Check warning on line 284 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L284

Added line #L284 was not covered by tests
else:
curl.unsetopt(_pycurl.USERPWD)

Check warning on line 286 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L286

Added line #L286 was not covered by tests

if request.client_cert is not None:
setopt(_pycurl.SSLCERT, request.client_cert)

Check warning on line 289 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L289

Added line #L289 was not covered by tests
if request.client_key is not None:
setopt(_pycurl.SSLKEY, request.client_key)

Check warning on line 291 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L291

Added line #L291 was not covered by tests

if request.on_prepare is not None:
request.on_prepare(curl)

Check warning on line 294 in kombu/asynchronous/http/curl.py

View check run for this annotation

Codecov / codecov/patch

kombu/asynchronous/http/curl.py#L294

Added line #L294 was not covered by tests
1 change: 1 addition & 0 deletions requirements/pkgutils.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ bumpversion==0.6.0
pydocstyle==6.3.0
mypy==1.14.1
typing_extensions==4.12.2; python_version<"3.10"
types-pycurl>=7.43.0.5; sys_platform != 'win32' and platform_python_implementation=="CPython"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is types-pycurl? did the package name changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was suggested by mypy. Otherwise mypy ci was failing

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weren't we using only pycurl?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I started to get this error only now, and types-pycurl was suggested. The error was related to mypy build (which I am not very familiar with). Then I saw other types-* are already used from the same repo. And then if pycurl is optional then full pycurl dependency is not required and types-pycurl would be sufficient to pass mypy build. I suppose mypy build does typechecking that is why it errored

Loading