File tree 2 files changed +7
-5
lines changed
2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,9 @@ async fn make_request(
20
20
. map_err ( map_hyper_error) ?;
21
21
let text = std:: str:: from_utf8 ( & buf) . map_err ( map_utf8_error) ?;
22
22
let mut response = Response :: ok ( text) ?;
23
- response. headers_mut ( ) . append ( "Content-Type" , "text/html" ) ?;
23
+ response
24
+ . headers_mut ( )
25
+ . append ( "Content-Type" , "text/html; charset=utf-8" ) ?;
24
26
Ok ( response)
25
27
}
26
28
#[ event( fetch) ]
Original file line number Diff line number Diff line change @@ -52,10 +52,10 @@ impl Response {
52
52
}
53
53
54
54
/// Create a `Response` using the body encoded as HTML. Sets the associated `Content-Type`
55
- /// header for the `Response` as `text/html`.
55
+ /// header for the `Response` as `text/html; charset=utf-8 `.
56
56
pub fn from_html ( html : impl AsRef < str > ) -> Result < Self > {
57
57
let mut headers = Headers :: new ( ) ;
58
- headers. set ( CONTENT_TYPE , "text/html" ) ?;
58
+ headers. set ( CONTENT_TYPE , "text/html; charset=utf-8 " ) ?;
59
59
60
60
let data = html. as_ref ( ) . as_bytes ( ) . to_vec ( ) ;
61
61
Ok ( Self {
@@ -130,10 +130,10 @@ impl Response {
130
130
}
131
131
132
132
/// Create a `Response` using unprocessed text provided. Sets the associated `Content-Type`
133
- /// header for the `Response` as `text/plain`.
133
+ /// header for the `Response` as `text/plain; charset=utf-8 `.
134
134
pub fn ok ( body : impl Into < String > ) -> Result < Self > {
135
135
let mut headers = Headers :: new ( ) ;
136
- headers. set ( CONTENT_TYPE , "text/plain" ) ?;
136
+ headers. set ( CONTENT_TYPE , "text/plain; charset=utf-8 " ) ?;
137
137
138
138
Ok ( Self {
139
139
body : ResponseBody :: Body ( body. into ( ) . into_bytes ( ) ) ,
You can’t perform that action at this time.
0 commit comments