File tree Expand file tree Collapse file tree
packages/sdk/js/src/v2/gen Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -162,10 +162,16 @@ export const createClient = (config: Config = {}): Client => {
162162 case "arrayBuffer" :
163163 case "blob" :
164164 case "formData" :
165- case "json" :
166165 case "text" :
167166 data = await response [ parseAs ] ( )
168167 break
168+ case "json" : {
169+ // Some servers return 200 with no Content-Length and empty body.
170+ // response.json() would throw; read as text and parse if non-empty.
171+ const text = await response . text ( )
172+ data = text ? JSON . parse ( text ) : { }
173+ break
174+ }
169175 case "stream" :
170176 return opts . responseStyle === "data"
171177 ? response . body
@@ -244,6 +250,7 @@ export const createClient = (config: Config = {}): Client => {
244250 }
245251 return request
246252 } ,
253+ serializedBody : getValidRequestBody ( opts ) as BodyInit | null | undefined ,
247254 url,
248255 } )
249256 }
Original file line number Diff line number Diff line change @@ -151,6 +151,8 @@ export const createSseClient = <TData = unknown>({
151151 const { done, value } = await reader . read ( )
152152 if ( done ) break
153153 buffer += value
154+ // Normalize line endings: CRLF -> LF, then CR -> LF
155+ buffer = buffer . replace ( / \r \n / g, "\n" ) . replace ( / \r / g, "\n" )
154156
155157 const chunks = buffer . split ( "\n\n" )
156158 buffer = chunks . pop ( ) ?? ""
You can’t perform that action at this time.
0 commit comments