@@ -86,6 +86,56 @@ describe.skip(FetchHttpHandler.name, () => {
8686 expect ( requestCall [ 0 ] ) . toBe ( "https://foo.amazonaws.com:443/test/?bar=baz" ) ;
8787 } ) ;
8888
89+ it ( "will omit body if method is GET" , async ( ) => {
90+ const mockResponse = {
91+ headers : { entries : jest . fn ( ) . mockReturnValue ( [ ] ) } ,
92+ blob : jest . fn ( ) . mockResolvedValue ( new Blob ( ) ) ,
93+ } ;
94+ const mockFetch = jest . fn ( ) . mockResolvedValue ( mockResponse ) ;
95+
96+ ( global as any ) . fetch = mockFetch ;
97+
98+ const httpRequest = new HttpRequest ( {
99+ headers : { } ,
100+ hostname : "foo.amazonaws.com" ,
101+ method : "GET" ,
102+ path : "/" ,
103+ body : "will be omitted" ,
104+ } ) ;
105+ const fetchHttpHandler = new FetchHttpHandler ( ) ;
106+
107+ await fetchHttpHandler . handle ( httpRequest , { } ) ;
108+
109+ expect ( mockFetch . mock . calls . length ) . toBe ( 1 ) ;
110+ const requestCall = mockRequest . mock . calls [ 0 ] ;
111+ expect ( requestCall [ 1 ] . body ) . toBeUndefined ( ) ;
112+ } ) ;
113+
114+ it ( "will omit body if method is HEAD" , async ( ) => {
115+ const mockResponse = {
116+ headers : { entries : jest . fn ( ) . mockReturnValue ( [ ] ) } ,
117+ blob : jest . fn ( ) . mockResolvedValue ( new Blob ( ) ) ,
118+ } ;
119+ const mockFetch = jest . fn ( ) . mockResolvedValue ( mockResponse ) ;
120+
121+ ( global as any ) . fetch = mockFetch ;
122+
123+ const httpRequest = new HttpRequest ( {
124+ headers : { } ,
125+ hostname : "foo.amazonaws.com" ,
126+ method : "HEAD" ,
127+ path : "/" ,
128+ body : "will be omitted" ,
129+ } ) ;
130+ const fetchHttpHandler = new FetchHttpHandler ( ) ;
131+
132+ await fetchHttpHandler . handle ( httpRequest , { } ) ;
133+
134+ expect ( mockFetch . mock . calls . length ) . toBe ( 1 ) ;
135+ const requestCall = mockRequest . mock . calls [ 0 ] ;
136+ expect ( requestCall [ 1 ] . body ) . toBeUndefined ( ) ;
137+ } ) ;
138+
89139 it ( "will not make request if already aborted" , async ( ) => {
90140 const mockResponse = {
91141 headers : {
0 commit comments