repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
gunicorn | gunicorn/uwsgi/errors.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
# We don't need to call super() in __init__ methods of our
# BaseException and Exception classes because we also define
# our own __str__ methods so there is no need to pass 'message'
# to the base class to get a m... | 47 | 1,318 |
gunicorn | gunicorn/uwsgi/__init__.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
from gunicorn.uwsgi.message import UWSGIRequest
from gunicorn.uwsgi.parser import UWSGIParser
from gunicorn.uwsgi.errors import (
UWSGIParseException,
InvalidUWSGIHeader,
UnsupportedModifier,
Forbid... | 22 | 502 |
gunicorn | gunicorn/uwsgi/message.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
from gunicorn.http.body import LengthReader, Body
from gunicorn.uwsgi.errors import (
InvalidUWSGIHeader,
UnsupportedModifier,
ForbiddenUWSGIRequest,
)
# Maximum number of variables to prevent DoS
MAX... | 241 | 8,189 |
gunicorn | gunicorn/ctl/server.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
Control Socket Server
Runs in the arbiter process and accepts commands via Unix socket.
Uses asyncio in a background thread to handle client connections.
Fork Safety:
This server uses os.register_at_fork(... | 420 | 13,827 |
gunicorn | gunicorn/ctl/__init__.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
Gunicorn Control Interface
Provides a control socket server for runtime management and
a CLI client (gunicornc) for interacting with running Gunicorn instances.
"""
from gunicorn.ctl.server import ControlSock... | 17 | 496 |
gunicorn | gunicorn/ctl/handlers.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
Control Interface Command Handlers
Provides handlers for all control commands with access to arbiter state.
"""
import os
import signal
import socket
import time
class CommandHandlers:
"""
Command h... | 586 | 18,207 |
gunicorn | gunicorn/ctl/protocol.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
Control Socket Protocol
JSON-based protocol with length-prefixed framing for the control interface.
Message Format:
+----------------+------------------+
| Length (4B BE) | JSON Payload |
+---... | 225 | 5,705 |
gunicorn | gunicorn/ctl/client.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
Control Socket Client
Client library for connecting to gunicorn control socket.
"""
import shlex
import socket
from gunicorn.ctl.protocol import (
ControlProtocol,
make_request,
)
class ControlClie... | 140 | 3,478 |
gunicorn | gunicorn/ctl/cli.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
gunicornc - Gunicorn control interface CLI
Interactive and single-command modes for controlling Gunicorn instances.
"""
import argparse
import json
import os
import sys
from gunicorn.config import _get_defau... | 451 | 13,202 |
gunicorn | gunicorn/workers/ggevent.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
import os
import sys
from datetime import datetime
from functools import partial
import time
try:
import gevent
except ImportError:
raise RuntimeError("gevent worker requires gevent 24.10.1 or higher")
els... | 191 | 5,885 |
gunicorn | gunicorn/workers/gasgi.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
ASGI worker for gunicorn.
Provides native asyncio-based ASGI support using gunicorn's own
HTTP parsing infrastructure.
"""
import asyncio
import os
import signal
import sys
from gunicorn.workers import base
... | 304 | 10,697 |
gunicorn | gunicorn/workers/__init__.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
# supported gunicorn workers.
SUPPORTED_WORKERS = {
"sync": "gunicorn.workers.sync.SyncWorker",
"gevent": "gunicorn.workers.ggevent.GeventWorker",
"gevent_wsgi": "gunicorn.workers.ggevent.GeventPyWSGIWo... | 15 | 560 |
gunicorn | gunicorn/workers/sync.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
#
from datetime import datetime
import errno
import os
import select
import ssl
import sys
from gunicorn import http
from gunicorn.http import wsgi
from gunicorn import sock
from gunicorn import util
from gunicorn... | 213 | 7,421 |
gunicorn | gunicorn/workers/gthread.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
# design:
# A threaded worker accepts connections in the main loop, accepted
# connections are added to the thread pool as a connection job.
# Keepalive connections are put back in the loop waiting for an event.
# ... | 714 | 26,573 |
gunicorn | gunicorn/workers/gtornado.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
import os
import sys
try:
import tornado
except ImportError:
raise RuntimeError("You need tornado installed to use this worker.")
import tornado.web
import tornado.httpserver
from tornado.ioloop import IOL... | 125 | 3,905 |
gunicorn | gunicorn/workers/base_async.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
from datetime import datetime
import errno
import socket
import ssl
import sys
from gunicorn import http
from gunicorn.http import wsgi
from gunicorn import util
from gunicorn import sock as gunicorn_sock
from gun... | 258 | 9,763 |
gunicorn | gunicorn/workers/workertmp.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
import os
import time
import platform
import tempfile
from gunicorn import util
PLATFORM = platform.system()
IS_CYGWIN = PLATFORM.startswith('CYGWIN')
class WorkerTmp:
def __init__(self, cfg):
old_... | 54 | 1,604 |
gunicorn | gunicorn/workers/base.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
import io
import os
import signal
import sys
import time
import traceback
from datetime import datetime
from random import randint
from ssl import SSLError
from gunicorn import util
from gunicorn.http.errors impor... | 288 | 9,899 |
gunicorn | gunicorn/app/wsgiapp.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
import os
from gunicorn.errors import ConfigError
from gunicorn.app.base import Application
from gunicorn import util
class WSGIApplication(Application):
def init(self, parser, opts, args):
self.app_... | 71 | 1,924 |
gunicorn | gunicorn/app/pasterapp.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
import configparser
import os
from paste.deploy import loadapp
from gunicorn.app.wsgiapp import WSGIApplication
from gunicorn.config import get_default_config_file
def get_wsgi_app(config_uri, name=None, defaul... | 75 | 2,016 |
gunicorn | gunicorn/app/base.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
import importlib.util
import importlib.machinery
import os
import sys
import traceback
from gunicorn import util
from gunicorn.arbiter import Arbiter
from gunicorn.config import Config, get_default_config_file
from... | 236 | 7,370 |
hypercorn | compliance/h2spec/server.py | .py | async def app(scope, receive, send):
while True:
event = await receive()
if event['type'] == 'http.disconnect':
break
elif event['type'] == 'http.request' and not event.get('more_body', False):
await send_data(send)
break
elif event['type'] == 'lif... | 26 | 808 |
hypercorn | compliance/autobahn/server.py | .py | async def app(scope, receive, send):
while True:
event = await receive()
if event['type'] == 'websocket.disconnect':
break
elif event['type'] == 'websocket.connect':
await send({'type': 'websocket.accept'})
elif event['type'] == 'websocket.receive':
... | 19 | 716 |
hypercorn | compliance/autobahn/summarise.py | .py | import json
import sys
with open('reports/servers/index.json') as file_:
report = json.load(file_)
failures = sum(value['behavior'] == 'FAILED' for value in report['websockets'].values())
if failures > 0:
sys.exit(1)
else:
sys.exit(0)
| 13 | 250 |
hypercorn | tests/test_app_wrappers.py | .py | from __future__ import annotations
import asyncio
from collections.abc import Callable
from functools import partial
from typing import Any
import pytest
import trio
from hypercorn.app_wrappers import _build_environ, InvalidPathError, WSGIWrapper
from hypercorn.typing import ASGIReceiveEvent, ASGISendEvent, Connecti... | 209 | 6,162 |
hypercorn | tests/test___main__.py | .py | from __future__ import annotations
import inspect
import os
from unittest.mock import Mock
import pytest
from _pytest.monkeypatch import MonkeyPatch
import hypercorn.__main__
from hypercorn.config import Config
def test_load_config_none() -> None:
assert isinstance(hypercorn.__main__._load_config(None), Config... | 86 | 2,898 |
hypercorn | tests/test_logging.py | .py | from __future__ import annotations
import logging
import os
import time
import pytest
from hypercorn.config import Config
from hypercorn.logging import AccessLogAtoms, Logger
from hypercorn.typing import HTTPScope, ResponseSummary
@pytest.mark.parametrize(
"target, expected_name, expected_handler_type",
[
... | 116 | 3,976 |
hypercorn | tests/test_config.py | .py | from __future__ import annotations
import os
import socket
import ssl
import sys
from unittest.mock import Mock, NonCallableMock
import pytest
from _pytest.monkeypatch import MonkeyPatch
import hypercorn.config
from hypercorn.config import Config
access_log_format = "bob"
h11_max_incomplete_size = 4
def _check_st... | 155 | 5,507 |
hypercorn | tests/helpers.py | .py | from __future__ import annotations
from collections.abc import Callable
from copy import deepcopy
from json import dumps
from socket import AF_INET
from typing import cast
from hypercorn.typing import ASGIReceiveCallable, ASGISendCallable, Scope, WWWScope
SANITY_BODY = b"Hello Hypercorn"
class MockSocket:
fami... | 110 | 4,027 |
hypercorn | tests/test_utils.py | .py | from __future__ import annotations
from collections.abc import Callable, Iterable
from typing import Any
import pytest
from hypercorn.typing import Scope
from hypercorn.utils import (
build_and_validate_headers,
filter_pseudo_headers,
is_asgi,
suppress_body,
)
@pytest.mark.parametrize(
"method,... | 83 | 2,169 |
hypercorn | tests/conftest.py | .py | from __future__ import annotations
import pytest
from _pytest.monkeypatch import MonkeyPatch
import hypercorn.config
from hypercorn.typing import ConnectionState, HTTPScope
@pytest.fixture(autouse=True)
def _time(monkeypatch: MonkeyPatch) -> None:
monkeypatch.setattr(hypercorn.config, "time", lambda: 5000)
@p... | 37 | 917 |
hypercorn | tests/trio/test_keep_alive.py | .py | from __future__ import annotations
from collections.abc import Awaitable, Callable, Generator
from typing import cast
import h11
import pytest
import trio
from hypercorn.app_wrappers import ASGIWrapper
from hypercorn.config import Config
from hypercorn.trio.tcp_server import TCPServer
from hypercorn.trio.worker_cont... | 123 | 4,129 |
hypercorn | tests/trio/test_sanity.py | .py | from __future__ import annotations
from typing import cast
from unittest.mock import AsyncMock, Mock, PropertyMock
import h2
import h11
import pytest
import trio
import wsproto
from hypercorn.app_wrappers import ASGIWrapper
from hypercorn.config import Config
from hypercorn.trio.tcp_server import TCPServer
from hype... | 210 | 8,563 |
hypercorn | tests/trio/test_lifespan.py | .py | from __future__ import annotations
import sys
if sys.version_info < (3, 11):
from exceptiongroup import ExceptionGroup
import pytest
import trio
from hypercorn.app_wrappers import ASGIWrapper
from hypercorn.config import Config
from hypercorn.trio.lifespan import Lifespan
from hypercorn.typing import ASGIReceiv... | 50 | 1,721 |
hypercorn | tests/protocol/test_h11.py | .py | from __future__ import annotations
import asyncio
from typing import Any
from unittest.mock import AsyncMock, call, Mock
import h11
import pytest
import pytest_asyncio
from _pytest.monkeypatch import MonkeyPatch
import hypercorn.protocol.h11
from hypercorn.asyncio.worker_context import EventWrapper
from hypercorn.co... | 416 | 15,088 |
hypercorn | tests/protocol/test_h2.py | .py | from __future__ import annotations
import asyncio
from unittest.mock import AsyncMock, call, Mock
import pytest
from h2.connection import H2Connection
from h2.events import ConnectionTerminated
from hypercorn.asyncio.worker_context import EventWrapper, WorkerContext
from hypercorn.config import Config
from hypercorn... | 119 | 3,601 |
hypercorn | tests/protocol/test_http_stream.py | .py | from __future__ import annotations
from typing import Any, cast
from unittest.mock import AsyncMock, call
import pytest
import pytest_asyncio
from hypercorn.asyncio.statsd import StatsdLogger
from hypercorn.asyncio.worker_context import WorkerContext
from hypercorn.config import Config
from hypercorn.logging import ... | 430 | 13,134 |
hypercorn | tests/protocol/test_ws_stream.py | .py | from __future__ import annotations
import asyncio
from typing import Any, cast
from unittest.mock import AsyncMock, call, Mock
import pytest
import pytest_asyncio
from wsproto.events import BytesMessage, TextMessage
from hypercorn.asyncio.task_group import TaskGroup
from hypercorn.asyncio.worker_context import Worke... | 552 | 18,061 |
hypercorn | tests/asyncio/test_keep_alive.py | .py | from __future__ import annotations
import asyncio
from collections.abc import AsyncGenerator
import h11
import pytest
import pytest_asyncio
from hypercorn.app_wrappers import ASGIWrapper
from hypercorn.asyncio.tcp_server import TCPServer
from hypercorn.asyncio.worker_context import WorkerContext
from hypercorn.confi... | 110 | 3,982 |
hypercorn | tests/asyncio/test_task_group.py | .py | from __future__ import annotations
import asyncio
from collections.abc import Callable
import pytest
from hypercorn.app_wrappers import ASGIWrapper
from hypercorn.asyncio.task_group import TaskGroup
from hypercorn.config import Config
from hypercorn.typing import HTTPScope, Scope
@pytest.mark.asyncio
async def tes... | 46 | 1,535 |
hypercorn | tests/asyncio/test_tcp_server.py | .py | from __future__ import annotations
import asyncio
import pytest
from hypercorn.app_wrappers import ASGIWrapper
from hypercorn.asyncio.tcp_server import TCPServer
from hypercorn.asyncio.worker_context import WorkerContext
from hypercorn.config import Config
from .helpers import MemoryReader, MemoryWriter
from ..helpe... | 56 | 1,651 |
hypercorn | tests/asyncio/test_sanity.py | .py | from __future__ import annotations
import asyncio
import h2
import h11
import pytest
import wsproto
from hypercorn.app_wrappers import ASGIWrapper
from hypercorn.asyncio.tcp_server import TCPServer
from hypercorn.asyncio.worker_context import WorkerContext
from hypercorn.config import Config
from .helpers import Mem... | 240 | 8,694 |
hypercorn | tests/asyncio/helpers.py | .py | from __future__ import annotations
import asyncio
from ..helpers import MockSocket
class MockSSLObject:
def selected_alpn_protocol(self) -> str:
return "h2"
class MemoryReader:
def __init__(self) -> None:
self.data: asyncio.Queue = asyncio.Queue()
self.eof = False
async def se... | 67 | 1,594 |
hypercorn | tests/asyncio/test_lifespan.py | .py | from __future__ import annotations
import asyncio
from collections.abc import Callable
from time import sleep
import pytest
from hypercorn.app_wrappers import ASGIWrapper
from hypercorn.asyncio.lifespan import Lifespan
from hypercorn.config import Config
from hypercorn.typing import ASGIReceiveCallable, ASGISendCall... | 92 | 3,065 |
hypercorn | tests/middleware/test_dispatcher.py | .py | from __future__ import annotations
from collections.abc import Callable
from typing import cast
import pytest
from hypercorn.middleware.dispatcher import AsyncioDispatcherMiddleware, TrioDispatcherMiddleware
from hypercorn.typing import HTTPScope, Scope
@pytest.mark.asyncio
async def test_dispatcher_middleware(htt... | 92 | 3,194 |
hypercorn | tests/middleware/test_proxy_fix.py | .py | from __future__ import annotations
from unittest.mock import AsyncMock
import pytest
from hypercorn.middleware import ProxyFixMiddleware
from hypercorn.typing import ConnectionState, HTTPScope
@pytest.mark.asyncio
async def test_proxy_fix_legacy() -> None:
mock = AsyncMock()
app = ProxyFixMiddleware(mock)
... | 74 | 2,197 |
hypercorn | tests/middleware/test_http_to_https.py | .py | from __future__ import annotations
import pytest
from hypercorn.middleware import HTTPToHTTPSRedirectMiddleware
from hypercorn.typing import ConnectionState, HTTPScope, WebsocketScope
from ..helpers import empty_framework
@pytest.mark.asyncio
@pytest.mark.parametrize("raw_path", [b"/abc", b"/abc%3C"])
async def tes... | 172 | 4,811 |
hypercorn | tests/e2e/test_httpx.py | .py | from __future__ import annotations
import httpx # type: ignore
import pytest
import trio
import hypercorn.trio
from hypercorn.config import Config
from hypercorn.typing import ASGIReceiveCallable, ASGISendCallable, Scope
async def app(scope, receive, send) -> None: # type: ignore
assert scope["type"] == "http... | 106 | 2,876 |
hypercorn | tests/assets/config.py | .py | from __future__ import annotations
import ssl # noqa: F401
access_log_format = "bob"
bind = "127.0.0.1:5555"
h11_max_incomplete_size = 4
| 8 | 140 |
hypercorn | tests/assets/config_ssl.py | .py | from __future__ import annotations
access_log_format = "bob"
bind = ["127.0.0.1:5555"]
certfile = "tests/assets/cert.pem"
ciphers = "ECDHE+AESGCM"
h11_max_incomplete_size = 4
keyfile = "tests/assets/key.pem"
| 9 | 209 |
hypercorn | src/hypercorn/logging.py | .py | from __future__ import annotations
import json
import logging
import os
import sys
import time
from collections.abc import Mapping
from http import HTTPStatus
from logging.config import dictConfig, fileConfig
from typing import Any, IO, TYPE_CHECKING
if sys.version_info >= (3, 11):
import tomllib
else:
import... | 204 | 7,335 |
hypercorn | src/hypercorn/utils.py | .py | from __future__ import annotations
import inspect
import os
import socket
import sys
from collections.abc import Awaitable, Callable, Iterable
from enum import Enum
from importlib import import_module
from multiprocessing.synchronize import Event as EventType
from pathlib import Path
from typing import Any, cast, Lite... | 209 | 6,444 |
hypercorn | src/hypercorn/__main__.py | .py | from __future__ import annotations
import argparse
import ssl
import sys
import warnings
from .config import Config
from .run import run
sentinel = object()
def _load_config(config_path: str | None) -> Config:
if config_path is None:
return Config()
elif config_path.startswith("python:"):
r... | 317 | 11,167 |
hypercorn | src/hypercorn/__init__.py | .py | from __future__ import annotations
from .config import Config
__all__ = ("Config",)
| 6 | 86 |
hypercorn | src/hypercorn/run.py | .py | from __future__ import annotations
import platform
import signal
import time
from multiprocessing import get_context
from multiprocessing.connection import wait
from multiprocessing.context import BaseContext
from multiprocessing.process import BaseProcess
from multiprocessing.synchronize import Event as EventType
fro... | 152 | 4,840 |
hypercorn | src/hypercorn/statsd.py | .py | from __future__ import annotations
from typing import Any, TYPE_CHECKING
from .logging import Logger
if TYPE_CHECKING:
from .config import Config
from .typing import ResponseSummary, WWWScope
METRIC_VAR = "metric"
VALUE_VAR = "value"
MTYPE_VAR = "mtype"
GAUGE_TYPE = "gauge"
COUNTER_TYPE = "counter"
HISTOGRA... | 97 | 3,870 |
hypercorn | src/hypercorn/typing.py | .py | from __future__ import annotations
from collections.abc import Awaitable, Callable, Iterable
from multiprocessing.synchronize import Event as EventType
from types import TracebackType
from typing import Any, Literal, NewType, Optional, Protocol, TypedDict
import h2.events
import h11
from .config import Config, Socke... | 361 | 7,892 |
hypercorn | src/hypercorn/config.py | .py | from __future__ import annotations
import importlib
import importlib.util
import logging
import os
import socket
import stat
import sys
import types
import warnings
from collections.abc import Mapping
from dataclasses import dataclass
from ssl import (
create_default_context,
OP_NO_COMPRESSION,
Purpose,
... | 411 | 13,419 |
hypercorn | src/hypercorn/app_wrappers.py | .py | from __future__ import annotations
import sys
from collections.abc import Callable
from functools import partial
from io import BytesIO
from .typing import (
ASGIFramework,
ASGIReceiveCallable,
ASGISendCallable,
HTTPScope,
Scope,
WSGIFramework,
)
class InvalidPathError(Exception):
pass
... | 168 | 5,516 |
hypercorn | src/hypercorn/events.py | .py | from __future__ import annotations
from abc import ABC
from dataclasses import dataclass
class Event(ABC):
pass
@dataclass(frozen=True)
class RawData(Event):
data: bytes
address: tuple[str, int] | None = None
@dataclass(frozen=True)
class Closed(Event):
pass
@dataclass(frozen=True)
class Update... | 25 | 345 |
hypercorn | src/hypercorn/trio/task_group.py | .py | from __future__ import annotations
import sys
from collections.abc import Awaitable, Callable
from contextlib import AbstractAsyncContextManager
from types import TracebackType
from typing import Any
import trio
from ..config import Config
from ..typing import AppWrapper, ASGIReceiveCallable, ASGIReceiveEvent, ASGIS... | 83 | 2,521 |
hypercorn | src/hypercorn/trio/worker_context.py | .py | from __future__ import annotations
from collections.abc import Awaitable, Callable
from functools import wraps
import trio
from ..typing import Event, SingleTask, TaskGroup
def _cancel_wrapper(func: Callable[[], Awaitable[None]]) -> Callable[[], Awaitable[None]]:
@wraps(func)
async def wrapper(
tas... | 84 | 2,262 |
hypercorn | src/hypercorn/trio/__init__.py | .py | from __future__ import annotations
import warnings
from collections.abc import Awaitable, Callable
from typing import Literal
import trio
from .run import worker_serve
from ..config import Config
from ..typing import Framework
from ..utils import wrap_app
async def serve(
app: Framework,
config: Config,
... | 54 | 1,569 |
hypercorn | src/hypercorn/trio/run.py | .py | from __future__ import annotations
import sys
from collections.abc import Awaitable, Callable
from functools import partial
from multiprocessing.synchronize import Event as EventType
from random import randint
import trio
from .lifespan import Lifespan
from .statsd import StatsdLogger
from .tcp_server import TCPServ... | 139 | 5,415 |
hypercorn | src/hypercorn/trio/statsd.py | .py | from __future__ import annotations
import trio
from ..config import Config
from ..statsd import StatsdLogger as Base
class StatsdLogger(Base):
def __init__(self, config: Config) -> None:
super().__init__(config)
self.address = tuple(config.statsd_host.rsplit(":", 1))
self.socket = trio.s... | 17 | 493 |
hypercorn | src/hypercorn/trio/tcp_server.py | .py | from __future__ import annotations
from collections.abc import Generator
from math import inf
from typing import Any
import trio
from .task_group import TaskGroup
from .worker_context import TrioSingleTask, WorkerContext
from ..config import Config
from ..events import Closed, Event, RawData, Updated
from ..protocol... | 141 | 4,705 |
hypercorn | src/hypercorn/trio/lifespan.py | .py | from __future__ import annotations
import sys
import trio
from ..config import Config
from ..typing import AppWrapper, ASGIReceiveEvent, ASGISendEvent, LifespanScope, LifespanState
from ..utils import LifespanFailureError, LifespanTimeoutError
if sys.version_info < (3, 11):
from exceptiongroup import BaseExcept... | 109 | 3,942 |
hypercorn | src/hypercorn/trio/udp_server.py | .py | from __future__ import annotations
import socket
import trio
from .task_group import TaskGroup
from .worker_context import WorkerContext
from ..config import Config
from ..events import Event, RawData
from ..typing import AppWrapper, ConnectionState, LifespanState
from ..utils import parse_socket_addr
MAX_RECV = 2*... | 55 | 1,720 |
hypercorn | src/hypercorn/protocol/h3.py | .py | from __future__ import annotations
from collections.abc import Awaitable, Callable
from aioquic.h3.connection import H3Connection
from aioquic.h3.events import DataReceived, HeadersReceived
from aioquic.h3.exceptions import NoAvailablePushIDError
from aioquic.quic.connection import QuicConnection
from aioquic.quic.ev... | 157 | 5,617 |
hypercorn | src/hypercorn/protocol/http_stream.py | .py | from __future__ import annotations
from collections.abc import Awaitable, Callable
from enum import auto, Enum
from time import time
from urllib.parse import unquote
from .events import (
Body,
EndBody,
Event,
InformationalResponse,
Request,
Response,
StreamClosed,
Trailers,
)
from ..c... | 262 | 10,018 |
hypercorn | src/hypercorn/protocol/h11.py | .py | from __future__ import annotations
from collections.abc import Awaitable, Callable
from itertools import chain
from typing import cast
import h11
from .events import (
Body,
Data,
EndBody,
EndData,
Event as StreamEvent,
InformationalResponse,
Request,
Response,
StreamClosed,
)
fro... | 324 | 11,873 |
hypercorn | src/hypercorn/protocol/ws_stream.py | .py | from __future__ import annotations
from collections.abc import Awaitable, Callable, Iterable
from enum import auto, Enum
from io import BytesIO, StringIO
from time import time
from urllib.parse import unquote
from wsproto.connection import Connection, ConnectionState, ConnectionType
from wsproto.events import (
B... | 386 | 15,174 |
hypercorn | src/hypercorn/protocol/__init__.py | .py | from __future__ import annotations
from collections.abc import Awaitable, Callable
from .h2 import H2Protocol
from .h11 import H2CProtocolRequiredError, H2ProtocolAssumedError, H11Protocol
from ..config import Config
from ..events import Event, RawData
from ..typing import AppWrapper, ConnectionState, TaskGroup, Work... | 97 | 2,966 |
hypercorn | src/hypercorn/protocol/h2.py | .py | from __future__ import annotations
from collections.abc import Awaitable, Callable
import h2
import h2.connection
import h2.events
import h2.exceptions
import priority
from .events import (
Body,
Data,
EndBody,
EndData,
Event as StreamEvent,
InformationalResponse,
Request,
Response,
... | 401 | 15,592 |
hypercorn | src/hypercorn/protocol/quic.py | .py | from __future__ import annotations
from collections.abc import Awaitable, Callable
from dataclasses import dataclass
from functools import partial
from aioquic.buffer import Buffer
from aioquic.h3.connection import H3_ALPN
from aioquic.quic.configuration import QuicConfiguration
from aioquic.quic.connection import Qu... | 158 | 5,761 |
hypercorn | src/hypercorn/protocol/events.py | .py | from __future__ import annotations
from dataclasses import dataclass
from hypercorn.typing import ConnectionState
@dataclass(frozen=True)
class Event:
stream_id: int
@dataclass(frozen=True)
class Request(Event):
headers: list[tuple[bytes, bytes]]
http_version: str
method: str
raw_path: bytes
... | 66 | 1,143 |
hypercorn | src/hypercorn/asyncio/task_group.py | .py | from __future__ import annotations
import asyncio
from collections.abc import Awaitable, Callable
from functools import partial
from types import TracebackType
from typing import Any
from ..config import Config
from ..typing import AppWrapper, ASGIReceiveCallable, ASGIReceiveEvent, ASGISendEvent, Scope
try:
from... | 76 | 2,240 |
hypercorn | src/hypercorn/asyncio/worker_context.py | .py | from __future__ import annotations
import asyncio
from collections.abc import Callable
from ..typing import Event, SingleTask, TaskGroup
class AsyncioSingleTask:
def __init__(self) -> None:
self._handle: asyncio.Task | None = None
self._lock = asyncio.Lock()
async def restart(self, task_gro... | 79 | 2,108 |
hypercorn | src/hypercorn/asyncio/__init__.py | .py | from __future__ import annotations
import warnings
from collections.abc import Awaitable, Callable
from typing import Literal
from .run import worker_serve
from ..config import Config
from ..typing import Framework
from ..utils import wrap_app
async def serve(
app: Framework,
config: Config,
*,
shut... | 48 | 1,455 |
hypercorn | src/hypercorn/asyncio/run.py | .py | from __future__ import annotations
import asyncio
import platform
import signal
import ssl
import sys
from collections.abc import Awaitable, Callable
from functools import partial
from multiprocessing.synchronize import Event as EventType
from os import getpid
from random import randint
from socket import socket
from ... | 242 | 8,085 |
hypercorn | src/hypercorn/asyncio/statsd.py | .py | from __future__ import annotations
import asyncio
from ..config import Config
from ..statsd import StatsdLogger as Base
class _DummyProto(asyncio.DatagramProtocol):
pass
class StatsdLogger(Base):
def __init__(self, config: Config) -> None:
super().__init__(config)
self.address = config.sta... | 26 | 738 |
hypercorn | src/hypercorn/asyncio/tcp_server.py | .py | from __future__ import annotations
import asyncio
from collections.abc import Generator
from ssl import SSLError
from typing import Any
from .task_group import TaskGroup
from .worker_context import AsyncioSingleTask, WorkerContext
from ..config import Config
from ..events import Closed, Event, RawData, Updated
from .... | 142 | 4,606 |
hypercorn | src/hypercorn/asyncio/lifespan.py | .py | from __future__ import annotations
import asyncio
import sys
from collections.abc import Callable
from functools import partial
from typing import Any
from ..config import Config
from ..typing import AppWrapper, ASGIReceiveEvent, ASGISendEvent, LifespanScope, LifespanState
from ..utils import LifespanFailureError, Li... | 124 | 4,401 |
hypercorn | src/hypercorn/asyncio/udp_server.py | .py | from __future__ import annotations
import asyncio
from typing import TYPE_CHECKING
from .task_group import TaskGroup
from .worker_context import WorkerContext
from ..config import Config
from ..events import Event, RawData
from ..typing import AppWrapper, ConnectionState, LifespanState
from ..utils import parse_socke... | 69 | 2,379 |
hypercorn | src/hypercorn/middleware/proxy_fix.py | .py | from __future__ import annotations
from collections.abc import Callable, Iterable
from copy import deepcopy
from typing import Literal
from ..typing import ASGIFramework, Scope
class ProxyFixMiddleware:
def __init__(
self,
app: ASGIFramework,
mode: Literal["legacy", "modern"] = "legacy",... | 81 | 2,691 |
hypercorn | src/hypercorn/middleware/wsgi.py | .py | from __future__ import annotations
import asyncio
from collections.abc import Callable, Iterable
from functools import partial
from typing import Any
from ..app_wrappers import WSGIWrapper
from ..typing import ASGIReceiveCallable, ASGISendCallable, Scope, WSGIFramework
MAX_BODY_SIZE = 2**16
WSGICallable = Callable[... | 51 | 1,516 |
hypercorn | src/hypercorn/middleware/http_to_https.py | .py | from __future__ import annotations
from collections.abc import Callable
from urllib.parse import urlunsplit
from ..typing import ASGIFramework, HTTPScope, Scope, WebsocketScope, WWWScope
class HTTPToHTTPSRedirectMiddleware:
def __init__(self, app: ASGIFramework, host: str | None) -> None:
self.app = app... | 68 | 2,615 |
hypercorn | src/hypercorn/middleware/__init__.py | .py | from __future__ import annotations
from .dispatcher import DispatcherMiddleware
from .http_to_https import HTTPToHTTPSRedirectMiddleware
from .proxy_fix import ProxyFixMiddleware
from .wsgi import AsyncioWSGIMiddleware, TrioWSGIMiddleware
__all__ = (
"AsyncioWSGIMiddleware",
"DispatcherMiddleware",
"HTTPT... | 15 | 401 |
hypercorn | src/hypercorn/middleware/dispatcher.py | .py | from __future__ import annotations
import asyncio
from collections.abc import Callable
from functools import partial
from ..asyncio.task_group import TaskGroup
from ..typing import ASGIFramework, ASGIReceiveEvent, Scope
MAX_QUEUE_SIZE = 10
class _DispatcherMiddleware:
def __init__(self, mounts: dict[str, ASGIF... | 112 | 4,403 |
eve | setup.py | .py | #!/usr/bin/env python
import io
import re
from collections import OrderedDict
from setuptools import find_packages, setup
DESCRIPTION = "Python REST API for Humans."
with open("README.rst") as f:
LONG_DESCRIPTION = f.read()
with io.open("eve/__init__.py", "rt", encoding="utf8") as f:
VERSION = re.search(r"__... | 69 | 2,191 |
eve | docs/_themes/flask_theme_support.py | .py | # flasky extensions. flasky pygments style based on tango style
from pygments.style import Style
from pygments.token import (Comment, Error, Generic, Keyword, Literal, Name,
Number, Operator, Other, Punctuation, String,
Whitespace)
class FlaskyStyle(Style):
... | 79 | 3,910 |
eve | tests/test_settings.py | .py | # -*- coding: utf-8 -*-
import copy
MONGO_HOST = "localhost"
MONGO_PORT = 27017
MONGO_USERNAME = MONGO1_USERNAME = "test_user"
MONGO_PASSWORD = MONGO1_PASSWORD = "test_pw"
MONGO_DBNAME, MONGO1_DBNAME = "eve_test", "eve_test1"
ID_FIELD = "_id"
RESOURCE_METHODS = ["GET", "POST", "DELETE"]
ITEM_METHODS = ["GET", "PATCH"... | 443 | 14,190 |
eve | tests/test_logging.py | .py | from testfixtures import log_capture
from . import TestBase
class TestUtils(TestBase):
"""collection, document and home_link methods (and resource_uri, which is
used by all of them) are tested in 'tests.methods' since we need an active
flaskapp context
"""
@log_capture()
def test_logging_inf... | 22 | 651 |
eve | tests/utils.py | .py | # -*- coding: utf-8 -*-
import copy
import hashlib
from datetime import datetime, timedelta
from bson.json_util import dumps
from eve.utils import (
config,
date_to_str,
debug_error_message,
document_etag,
extract_key_values,
import_from_string,
parse_request,
querydef,
str_to_dat... | 350 | 15,123 |
eve | tests/test_prefix.py | .py | # -*- coding: utf-8 -*-
RESOURCE_METHODS = ["GET", "POST"]
URL_PREFIX = "prefix"
DOMAIN = {"contacts": {}}
| 6 | 108 |
eve | tests/test_version.py | .py | # -*- coding: utf-8 -*-
API_VERSION = "v1"
DOMAIN = {"contacts": {}}
| 5 | 70 |
eve | tests/__init__.py | .py | # -*- coding: utf-8 -*-
import os
import random
import string
import unittest
from datetime import datetime, timedelta, timezone
import simplejson as json
from bson import ObjectId
from pymongo import MongoClient
import eve
from eve import ETAG, ISSUES
from eve.methods.common import field_definition
from .test_setti... | 647 | 22,402 |
eve | tests/auth.py | .py | # -*- coding: utf-8 -*-
from io import BytesIO
import simplejson as json
from bson import ObjectId
import eve
from eve import Eve
from eve.auth import BasicAuth, HMACAuth, TokenAuth
from . import TestBase
from .test_settings import MONGO_DBNAME
class ValidBasicAuth(BasicAuth):
def __init__(self):
self.... | 931 | 34,630 |
eve | tests/test_prefix_version.py | .py | # -*- coding: utf-8 -*-
URL_PREFIX = "prefix"
API_VERSION = "v1"
DOMAIN = {"contacts": {}}
| 6 | 92 |
eve | tests/renders.py | .py | # -*- coding: utf-8 -*-
import simplejson as json
from bson import ObjectId
from eve.utils import api_prefix
from . import TestBase
from .test_settings import MONGO_DBNAME
class TestRenders(TestBase):
def test_default_render(self):
r = self.test_client.get("/")
self.assertEqual(r.content_type, ... | 378 | 16,373 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.