fix: add appendHeader parameter for merge/replace origin headers
Showing
1 changed file
with
7 additions
and
0 deletions
| @@ -86,10 +86,17 @@ class Request<T> { | @@ -86,10 +86,17 @@ class Request<T> { | ||
| 86 | FormData? files, | 86 | FormData? files, | 
| 87 | bool persistentConnection = true, | 87 | bool persistentConnection = true, | 
| 88 | Decoder<T>? decoder, | 88 | Decoder<T>? decoder, | 
| 89 | + bool appendHeader = true, | ||
| 89 | }) { | 90 | }) { | 
| 90 | if (followRedirects) { | 91 | if (followRedirects) { | 
| 91 | assert(maxRedirects > 0); | 92 | assert(maxRedirects > 0); | 
| 92 | } | 93 | } | 
| 94 | + | ||
| 95 | + // If appendHeader is set to true, we will merge origin headers with that | ||
| 96 | + if (appendHeader && headers != null) { | ||
| 97 | + headers.addAll(this.headers); | ||
| 98 | + } | ||
| 99 | + | ||
| 93 | return Request._( | 100 | return Request._( | 
| 94 | url: url ?? this.url, | 101 | url: url ?? this.url, | 
| 95 | method: method ?? this.method, | 102 | method: method ?? this.method, | 
- 
Please register or login to post a comment