Skip to content

Commit

Permalink
Apply fixes from geldata#7963
Browse files Browse the repository at this point in the history
  • Loading branch information
mmastrac committed Nov 19, 2024
1 parent 7516477 commit d9c953e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 3 additions & 0 deletions edb/server/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,9 @@ class SSEEvent:
data: str
id: Optional[str] = None

def json(self):
return json_lib.loads(self.data)

def close(self):
if not self.closed():
self._closed[0] = True
Expand Down
10 changes: 7 additions & 3 deletions edb/server/http/src/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,13 @@ async fn request_sse(
let guard = guard((), |_| trace!("Exiting SSE due to cancellation"));
let response = request(client, url, method, body, headers).await?;

if response.headers().get("content-type")
!= Some(&HeaderValue::from_static("text/event-stream"))
{
let content_type = response.headers().get("content-type");
let is_event_stream = content_type
.and_then(|v| v.to_str().ok())
.map(|s| s.starts_with("text/event-stream"))
.unwrap_or(false);

if !is_event_stream {
let headers = process_headers(response.headers());
let status = response.status();
let body = match response.bytes().await {
Expand Down

0 comments on commit d9c953e

Please sign in to comment.