@@ -131,27 +131,26 @@ def __init__(self, endpoint: str, security_settings: TransportSecuritySettings |
131131 # Remove automatic leading slash enforcement to support proper URL joining
132132 # Store the endpoint as-is, allowing both "/messages/" and "messages/" formats
133133 self ._endpoint = endpoint
134-
135134 self ._read_stream_writers = {}
136135 self ._security = TransportSecurityMiddleware (security_settings )
137136 logger .debug (f"SseServerTransport initialized with endpoint: { endpoint } " )
138137
139138 def _build_message_path (self , root_path : str ) -> str :
140139 """
141140 Helper method to properly construct the message path
142-
141+
143142 This method handles the path construction logic that was causing issues
144143 with urllib.parse.urljoin() when servers are proxied or mounted at subpaths.
145-
144+
146145 Args:
147146 root_path: The root path from ASGI scope (e.g., "" or "/api_prefix")
148-
147+
149148 Returns:
150149 The properly constructed path for client message posting
151150 """
152151 # Clean up the root path
153152 clean_root_path = root_path .rstrip ("/" )
154-
153+
155154 # If endpoint starts with "/", it's meant to be absolute within the app
156155 # If endpoint doesn't start with "/", it's meant to be relative to root_path
157156 if self ._endpoint .startswith ("/" ):
@@ -163,7 +162,7 @@ def _build_message_path(self, root_path: str) -> str:
163162 full_path = clean_root_path + "/" + self ._endpoint
164163 else :
165164 full_path = "/" + self ._endpoint
166-
165+
167166 return full_path
168167
169168 @asynccontextmanager
@@ -286,4 +285,4 @@ async def handle_post_message(self, scope: Scope, receive: Receive, send: Send)
286285 logger .debug (f"Sending session message to writer: { session_message } " )
287286 response = Response ("Accepted" , status_code = 202 )
288287 await response (scope , receive , send )
289- await writer .send (session_message )
288+ await writer .send (session_message )
0 commit comments