Skip to content

Commit ce636ac

Browse files
committed
update
1 parent 1cdeb92 commit ce636ac

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

lambda-http/src/streaming.rs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -68,33 +68,6 @@ where
6868
}
6969
}
7070

71-
/// Converts an `http::Response<B>` into a streaming Lambda response.
72-
fn into_stream_response<B>(res: Response<B>) -> StreamResponse<BodyStream<B>>
73-
where
74-
B: Body + Unpin + Send + 'static,
75-
B::Data: Into<Bytes> + Send,
76-
B::Error: Into<Error> + Send + Debug,
77-
{
78-
let (parts, body) = res.into_parts();
79-
80-
let mut headers = parts.headers;
81-
let cookies = headers
82-
.get_all(SET_COOKIE)
83-
.iter()
84-
.map(|c| String::from_utf8_lossy(c.as_bytes()).to_string())
85-
.collect::<Vec<_>>();
86-
headers.remove(SET_COOKIE);
87-
88-
StreamResponse {
89-
metadata_prelude: MetadataPrelude {
90-
headers,
91-
status_code: parts.status,
92-
cookies,
93-
},
94-
stream: BodyStream { body },
95-
}
96-
}
97-
9871
/// Builds a streaming-aware Tower service from a `Service<Request>` **without**
9972
/// boxing its future (no heap allocation / vtable).
10073
///
@@ -127,6 +100,33 @@ where
127100
.map_response(into_stream_response)
128101
}
129102

103+
/// Converts an `http::Response<B>` into a streaming Lambda response.
104+
fn into_stream_response<B>(res: Response<B>) -> StreamResponse<BodyStream<B>>
105+
where
106+
B: Body + Unpin + Send + 'static,
107+
B::Data: Into<Bytes> + Send,
108+
B::Error: Into<Error> + Send + Debug,
109+
{
110+
let (parts, body) = res.into_parts();
111+
112+
let mut headers = parts.headers;
113+
let cookies = headers
114+
.get_all(SET_COOKIE)
115+
.iter()
116+
.map(|c| String::from_utf8_lossy(c.as_bytes()).to_string())
117+
.collect::<Vec<_>>();
118+
headers.remove(SET_COOKIE);
119+
120+
StreamResponse {
121+
metadata_prelude: MetadataPrelude {
122+
headers,
123+
status_code: parts.status,
124+
cookies,
125+
},
126+
stream: BodyStream { body },
127+
}
128+
}
129+
130130
/// Runs the Lambda runtime with a handler that returns **streaming** HTTP
131131
/// responses.
132132
///

0 commit comments

Comments
 (0)