Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Middleware and decorator for processing TLSv1.3 early data requests in Starlette

Project description


Middleware and decorator for processing TLSv1.3 early data requests in Starlette

Package on PyPI

Install: pip install starlette-early-data

What this package can do:

  • Detect if request is early data and mark it (request.state.early_data = True)
  • Deny all early data requests (pass deny_all=True to add_middleware)
  • Deny early data requests to specific endpoints (use decorator @deny_early_data)

Example (

import uvicorn

from starlette.applications import Starlette
from starlette.requests import Request
from starlette.responses import PlainTextResponse

from starlette_early_data import EarlyDataMiddleware, deny_early_data

app = Starlette()
app.add_middleware(EarlyDataMiddleware, deny_all=False)

async def home(request: Request) -> PlainTextResponse:
    return PlainTextResponse("Always OK if deny_all=False")

async def security_risk(request: Request) -> PlainTextResponse:
    return PlainTextResponse("Security action done after handshake")

if __name__ == "__main__":, host="", port=8080)

Send request to with header Early-Data=1 and you will get 425.

Request to with the same header will only return 425 if you pass deny_all=True to app.add_middleware(...)

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for starlette-early-data, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size starlette_early_data-1.0.0-py3-none-any.whl (4.7 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size starlette-early-data-1.0.0.tar.gz (3.4 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page