Skip to content

Commit f79a25a

Browse files
committed
fix: 🐛 body overrides headers + multipart not retrying
2 parents 597caf2 + 0b9a1d2 commit f79a25a

13 files changed

+35
-26
lines changed

.all-contributorsrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,16 @@
143143
"ideas",
144144
"code"
145145
]
146+
},
147+
{
148+
"login": "vixez",
149+
"name": "Glenn Ruysschaert",
150+
"avatar_url": "https://avatars.githubusercontent.com/u/3032294?v=4",
151+
"profile": "http://www.glennruysschaert.com",
152+
"contributions": [
153+
"code",
154+
"test"
155+
]
146156
}
147157
],
148158
"contributorsPerLine": 7,

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
## 2.0.0-beta.2
44

55
- 🐞  Fixed: Changing `body` causes that the `headers` also change and ignore previous interceptions (i.e. content-type headers are overriden).
6+
- 🐞  Fixed: `copyWith` was missing fields
7+
- 🚦  Tests: Updated tests.
68

79
## 2.0.0-beta.1
810

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<!-- prettier-ignore-start -->
1010
<!-- markdownlint-disable -->
1111
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
12-
[![All Contributors](https://img.shields.io/badge/all_contributors-13-orange.svg?style=flat-square)](#contributors-)
12+
[![All Contributors](https://img.shields.io/badge/all_contributors-14-orange.svg?style=flat-square)](#contributors-)
1313
<!-- ALL-CONTRIBUTORS-BADGE:END -->
1414
<!-- markdownlint-restore -->
1515
<!-- prettier-ignore-end -->
@@ -300,6 +300,7 @@ Thanks to all the wonderful people contributing to improve this package. Check t
300300
<td align="center"><a href="https://github.com/Mawi137"><img src="https://avatars.githubusercontent.com/u/5464100?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Martijn</b></sub></a><br /><a href="https://github.com/CodingAleCR/http_interceptor/commits?author=Mawi137" title="Tests">⚠️</a> <a href="https://github.com/CodingAleCR/http_interceptor/commits?author=Mawi137" title="Code">💻</a></td>
301301
<td align="center"><a href="https://github.com/MaciejZuk"><img src="https://avatars.githubusercontent.com/u/78476165?v=4?s=100" width="100px;" alt=""/><br /><sub><b>MaciejZuk</b></sub></a><br /><a href="https://github.com/CodingAleCR/http_interceptor/issues?q=author%3AMaciejZuk" title="Bug reports">🐛</a></td>
302302
<td align="center"><a href="http://lukaskurz.com"><img src="https://avatars.githubusercontent.com/u/22956519?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Lukas Kurz</b></sub></a><br /><a href="https://github.com/CodingAleCR/http_interceptor/commits?author=lukaskurz" title="Tests">⚠️</a> <a href="#ideas-lukaskurz" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/CodingAleCR/http_interceptor/commits?author=lukaskurz" title="Code">💻</a></td>
303+
<td align="center"><a href="http://www.glennruysschaert.com"><img src="https://avatars.githubusercontent.com/u/3032294?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Glenn Ruysschaert</b></sub></a><br /><a href="https://github.com/CodingAleCR/http_interceptor/commits?author=vixez" title="Code">💻</a> <a href="https://github.com/CodingAleCR/http_interceptor/commits?author=vixez" title="Tests">⚠️</a></td>
303304
</tr>
304305
</table>
305306

example/lib/main.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import 'dart:developer';
33
import 'dart:io';
44

55
import 'package:flutter/material.dart';
6-
import 'package:http/src/base_request.dart';
7-
import 'package:http/src/base_response.dart';
86
import 'package:http_interceptor/http_interceptor.dart';
97
import 'package:shared_preferences/shared_preferences.dart';
108

lib/extensions/multipart_request.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ extension MultipartRequestCopyWith on MultipartRequest {
1919
method?.asString ?? this.method,
2020
url ?? this.url,
2121
)
22-
..headers.addAll(headers ?? {})
23-
..fields.addAll(fields ?? {})
24-
..files.addAll(files ?? [])
22+
..headers.addAll(headers ?? this.headers)
23+
..fields.addAll(fields ?? this.fields)
24+
..files.addAll(files ?? this.files)
2525
..followRedirects = followRedirects ?? this.followRedirects
2626
..maxRedirects = maxRedirects ?? this.maxRedirects
2727
..persistentConnection =

lib/extensions/streamed_request.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ extension StreamedRequestCopyWith on StreamedRequest {
1818
method?.asString ?? this.method,
1919
url ?? this.url,
2020
)
21-
..headers.addAll(headers ?? {})
21+
..headers.addAll(headers ?? this.headers)
2222
..followRedirects = followRedirects ?? this.followRedirects
2323
..maxRedirects = maxRedirects ?? this.maxRedirects
2424
..persistentConnection =

lib/http/intercepted_client.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,7 @@ class InterceptedClient extends BaseClient {
205205

206206
@override
207207
Future<StreamedResponse> send(BaseRequest request) async {
208-
final interceptedRequest = await _interceptRequest(request);
209-
210-
final response = await _inner.send(interceptedRequest);
208+
final response = await _attemptRequest(request);
211209

212210
final interceptedResponse = await _interceptResponse(response);
213211

lib/http/intercepted_http.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@ import 'dart:async';
22
import 'dart:convert';
33
import 'dart:typed_data';
44

5-
import 'package:http/http.dart';
65
import 'package:http_interceptor/http_interceptor.dart';
76

8-
import 'intercepted_client.dart';
9-
import 'interceptor_contract.dart';
10-
117
/// Class to be used by the user as a replacement for 'http' with interceptor
128
/// support.
139
///

test/extensions/base_reponse_test.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import 'package:http/http.dart';
21
import 'package:http_interceptor/http_interceptor.dart';
32
import 'package:test/test.dart';
43

test/extensions/base_request_test.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import 'dart:convert';
22

3-
import 'package:http/http.dart';
43
import 'package:http_interceptor/http_interceptor.dart';
54
import 'package:test/test.dart';
65

0 commit comments

Comments
 (0)