Skip to content

Commit

Permalink
[http] rename Event to HttpEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
jlaine committed Aug 11, 2019
1 parent 12f227b commit cb553fa
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
6 changes: 3 additions & 3 deletions aioquic/h0/connection.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Dict, List, Tuple

from aioquic.h3.events import DataReceived, Event, RequestReceived, ResponseReceived
from aioquic.h3.events import DataReceived, HttpEvent, RequestReceived, ResponseReceived
from aioquic.quic.connection import QuicConnection
from aioquic.quic.events import QuicEvent, StreamDataReceived

Expand All @@ -15,8 +15,8 @@ def __init__(self, quic: QuicConnection):
self._is_client = quic.configuration.is_client
self._quic = quic

def handle_event(self, event: QuicEvent) -> List[Event]:
http_events: List[Event] = []
def handle_event(self, event: QuicEvent) -> List[HttpEvent]:
http_events: List[HttpEvent] = []

if isinstance(event, StreamDataReceived) and (event.stream_id % 4) == 0:
data = event.data
Expand Down
12 changes: 6 additions & 6 deletions aioquic/h3/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from aioquic.buffer import Buffer, BufferReadError, encode_uint_var
from aioquic.h3.events import (
DataReceived,
Event,
Headers,
HttpEvent,
RequestReceived,
ResponseReceived,
)
Expand Down Expand Up @@ -108,7 +108,7 @@ def __init__(self, quic: QuicConnection):

self._init_connection()

def handle_event(self, event: QuicEvent) -> List[Event]:
def handle_event(self, event: QuicEvent) -> List[HttpEvent]:
"""
Handle a QUIC event and return a list of HTTP events.
Expand Down Expand Up @@ -191,11 +191,11 @@ def _init_connection(self) -> None:

def _receive_stream_data_bidi(
self, stream_id: int, data: bytes, stream_ended: bool
) -> List[Event]:
) -> List[HttpEvent]:
"""
Client-initiated bidirectional streams carry requests and responses.
"""
http_events: List[Event] = []
http_events: List[HttpEvent] = []

stream = self._stream[stream_id]
stream.buffer += data
Expand Down Expand Up @@ -285,8 +285,8 @@ def _receive_stream_data_bidi(

return http_events

def _receive_stream_data_uni(self, stream_id: int, data: bytes) -> List[Event]:
http_events: List[Event] = []
def _receive_stream_data_uni(self, stream_id: int, data: bytes) -> List[HttpEvent]:
http_events: List[HttpEvent] = []

stream = self._stream[stream_id]
stream.buffer += data
Expand Down
8 changes: 4 additions & 4 deletions aioquic/h3/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Headers = List[Tuple[bytes, bytes]]


class Event:
class HttpEvent:
"""
Base class for HTTP/3 events.
"""
Expand All @@ -13,7 +13,7 @@ class Event:


@dataclass
class DataReceived(Event):
class DataReceived(HttpEvent):
"""
The DataReceived event is fired whenever data is received on a stream from
the remote peer.
Expand All @@ -30,7 +30,7 @@ class DataReceived(Event):


@dataclass
class RequestReceived(Event):
class RequestReceived(HttpEvent):
"""
The RequestReceived event is fired whenever request headers are received.
"""
Expand All @@ -46,7 +46,7 @@ class RequestReceived(Event):


@dataclass
class ResponseReceived(Event):
class ResponseReceived(HttpEvent):
"""
The ResponseReceived event is fired whenever response headers are received.
"""
Expand Down
8 changes: 4 additions & 4 deletions examples/http3-client.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from aioquic.asyncio.protocol import QuicConnectionProtocol
from aioquic.h0.connection import H0Connection
from aioquic.h3.connection import H3Connection
from aioquic.h3.events import DataReceived, Event, ResponseReceived
from aioquic.h3.events import DataReceived, HttpEvent, ResponseReceived
from aioquic.quic.configuration import QuicConfiguration
from aioquic.quic.connection import NetworkAddress, QuicConnection
from aioquic.quic.events import ConnectionTerminated, QuicEvent
Expand Down Expand Up @@ -49,15 +49,15 @@ def __init__(
self._http: HttpConnection
self._server_addr = server_addr

self._request_events: Dict[int, Deque[Event]] = {}
self._request_waiter: Dict[int, asyncio.Future[Deque[Event]]] = {}
self._request_events: Dict[int, Deque[HttpEvent]] = {}
self._request_waiter: Dict[int, asyncio.Future[Deque[HttpEvent]]] = {}

if configuration.alpn_protocols[0].startswith("hq-"):
self._http = H0Connection(self._quic)
else:
self._http = H3Connection(self._quic)

async def get(self, netloc: str, path: str) -> Deque[Event]:
async def get(self, netloc: str, path: str) -> Deque[HttpEvent]:
"""
Perform a GET request.
"""
Expand Down
6 changes: 3 additions & 3 deletions examples/http3-server.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from aioquic.buffer import Buffer
from aioquic.h0.connection import H0Connection
from aioquic.h3.connection import H3Connection
from aioquic.h3.events import DataReceived, Event, RequestReceived
from aioquic.h3.events import DataReceived, HttpEvent, RequestReceived
from aioquic.quic.configuration import QuicConfiguration
from aioquic.quic.connection import NetworkAddress, QuicConnection
from aioquic.quic.events import QuicEvent
Expand Down Expand Up @@ -208,9 +208,9 @@ def quic_event_received(self, event: QuicEvent):
#  pass event to the HTTP layer
if self._http is not None:
for http_event in self._http.handle_event(event):
self.handle_http_event(http_event)
self.http_event_received(http_event)

def handle_http_event(self, event: Event) -> None:
def http_event_received(self, event: HttpEvent) -> None:
if isinstance(event, RequestReceived):
headers = []
raw_path = b""
Expand Down

0 comments on commit cb553fa

Please sign in to comment.