File tree Expand file tree Collapse file tree
packages/basic/src/utils/create Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import { fetchEventSource , EventSourceMessage } from " @microsoft/fetch-event-source" ;
2- import { genBaseOptions } from " ./index" ;
1+ import { fetchEventSource , EventSourceMessage } from ' @microsoft/fetch-event-source' ;
2+ import { genBaseOptions } from ' ./index' ;
33
44const MAX_RETRY_TIME = 0 ;
5- const EventStreamContentType = " text/event-stream" ;
5+ const EventStreamContentType = ' text/event-stream' ;
66
77export const sseRequester = function ( requestInfo ) {
88 const { url, config = { } } = requestInfo ;
@@ -39,8 +39,9 @@ export const sseRequester = function (requestInfo) {
3939 if ( leftRetries < 0 ) {
4040 close ( ) ;
4141 }
42- const contentType = response . headers . get ( "content-type" ) ;
43- if ( contentType !== EventStreamContentType ) {
42+ const contentType = response . headers . get ( 'content-type' ) ;
43+ // content-type可能返回包含charset等信息,因此需要包含判断
44+ if ( ! contentType . includes ( EventStreamContentType ) ) {
4445 throw new Error ( `Expected content-type to be ${ EventStreamContentType } , Actual: ${ contentType } ` ) ;
4546 }
4647 } ,
You can’t perform that action at this time.
0 commit comments