File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,11 @@ component accessors="true" {
3737 return makeRequest ();
3838 }
3939
40+ function withHeaders ( headers = {} ) {
41+ structEach ( headers , setHeader );
42+ return this ;
43+ }
44+
4045 function setHeader ( name , value ) {
4146 variables .headers [ lcase ( name ) ] = value ;
4247 return this ;
Original file line number Diff line number Diff line change @@ -23,6 +23,17 @@ component extends="testbox.system.BaseSpec" {
2323 expect ( req .getMethod () ).toBe ( " PATCH" );
2424 } );
2525
26+ it ( " can set multiple headers at once" , function () {
27+ expect ( req .getHeader ( " Accept" ) ).toBe ( " " );
28+ expect ( req .getHeader ( " X-Requested-With" ) ).toBe ( " " );
29+ req .withHeaders ( {
30+ " Accept" = " application/xml" ,
31+ " X-Requested-With" = " XMLHTTPRequest"
32+ } );
33+ expect ( req .getHeader ( " Accept" ) ).toBe ( " application/xml" );
34+ expect ( req .getHeader ( " X-Requested-With" ) ).toBe ( " XMLHTTPRequest" );
35+ } );
36+
2637 it ( " throws an exception if the url is empty when trying to make a request" , function () {
2738 expect ( function () {
2839 req .get ();
You can’t perform that action at this time.
0 commit comments