Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor WebSocket support into separate sync/async implementations #206

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
Use a proper ctypes.Structure for CurlWsFrame
  • Loading branch information
dolfies committed Jan 4, 2024
commit 541f2b6b7db5394f24888edc4b3d8e7caf75bebf
24 changes: 17 additions & 7 deletions curl_cffi/curl.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from __future__ import annotations

import ctypes
import re
import warnings
from http.cookies import SimpleCookie
from typing import Any, List, Tuple, Union
from typing import TYPE_CHECKING, Any, List, Tuple, Union

import certifi

Expand All @@ -14,12 +15,21 @@
DEFAULT_CACERT = certifi.where()


class CurlWsFrame(ffi.CData):
age: int
flags: int
offset: int
bytesleft: int
len: int
class CurlWsFrame(ctypes.Structure):
_fields_ = [
("age", ctypes.c_int),
("flags", ctypes.c_int),
("offset", ctypes.c_uint64),
("bytesleft", ctypes.c_uint64),
("len", ctypes.c_size_t),
]

if TYPE_CHECKING:
age: int
flags: int
offset: int
bytesleft: int
len: int


class CurlError(Exception):
Expand Down
Loading