File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -221,14 +221,7 @@ void CheckSuccess(string content)
221221 ? JsonConvert . DeserializeObject < T > ( json , JsonSerializerSettings )
222222 : default ( T ) ;
223223
224- case "application/octet-stream" :
225- case "image/png" :
226- CheckSuccess ( "<Stream>" ) ;
227- if ( typeof ( T ) != typeof ( Stream ) )
228- throw new Exception ( "API returned file, but no file was expected" ) ;
229- return readResponse
230- ? ( T ) ( object ) await response . Content . ReadAsStreamAsync ( )
231- : default ( T ) ;
224+
232225
233226 case "text/csv" :
234227 var csv = await response . Content . ReadAsStringAsync ( ) ;
@@ -237,6 +230,14 @@ void CheckSuccess(string content)
237230 throw new Exception ( $ "API returned csv, but expected type is { typeof ( T ) } ") ;
238231 return ( T ) ( object ) csv ;
239232 default :
233+ if ( typeof ( T ) == typeof ( Stream ) )
234+ {
235+ CheckSuccess ( "<Stream>" ) ;
236+ return readResponse
237+ ? ( T ) ( object ) await response . Content . ReadAsStreamAsync ( )
238+ : default ( T ) ;
239+ }
240+
240241 var content = await response . Content . ReadAsStringAsync ( ) ;
241242 CheckSuccess ( content ) ;
242243
You can’t perform that action at this time.
0 commit comments