@@ -532,6 +532,17 @@ describe('createHttpService', () => {
532532 ) ;
533533 } ) ;
534534
535+ it ( 'throws when content-type header is non-string (axios 1.15+ AxiosHeaderValue)' , async ( ) => {
536+ // Arrange — axios 1.15+ types header values as
537+ // `AxiosHeaders | string | string[] | number | boolean | null`. Non-string values
538+ // fall through `asString` to undefined, hitting the same path as a missing header.
539+ mock . onGet ( `${ BASE_URL } /download/odd` ) . reply ( 200 , 'data' , { 'content-type' : null as unknown as string } ) ;
540+ const service = createHttpService ( BASE_URL ) ;
541+
542+ // Act & Assert
543+ await expect ( service . downloadRequest ( '/download/odd' , 'file.bin' ) ) . rejects . toThrow ( 'No content type found' ) ;
544+ } ) ;
545+
535546 it ( 'revokes the object URL after triggering the download' , async ( ) => {
536547 // Arrange
537548 mock . onGet ( `${ BASE_URL } /download/file.pdf` ) . reply ( 200 , 'file-content' , { 'content-type' : 'application/pdf' } ) ;
@@ -577,6 +588,22 @@ describe('createHttpService', () => {
577588 const BlobMock = globalThis . Blob as unknown as ReturnType < typeof vi . fn > ;
578589 expect ( BlobMock ) . toHaveBeenCalledWith ( [ 'blob-data' ] , { type : 'application/octet-stream' } ) ;
579590 } ) ;
591+
592+ it ( 'uses fallback content type when header is non-string (axios 1.15+ AxiosHeaderValue)' , async ( ) => {
593+ // Arrange — axios 1.15+ types header values as a union including arrays, numbers,
594+ // booleans, and null. Any non-string value falls through `asString` and hits the
595+ // same fallback path as a missing header.
596+ mock . onGet ( `${ BASE_URL } /preview/doc` ) . reply ( 200 , 'blob-data' , { 'content-type' : null as unknown as string } ) ;
597+ const service = createHttpService ( BASE_URL ) ;
598+
599+ // Act
600+ const url = await service . previewRequest ( '/preview/doc' ) ;
601+
602+ // Assert
603+ expect ( url ) . toBe ( 'blob:http://localhost/fake-object-url' ) ;
604+ const BlobMock = globalThis . Blob as unknown as ReturnType < typeof vi . fn > ;
605+ expect ( BlobMock ) . toHaveBeenCalledWith ( [ 'blob-data' ] , { type : 'application/octet-stream' } ) ;
606+ } ) ;
580607 } ) ;
581608
582609 describe ( 'streamRequest' , ( ) => {
0 commit comments