@@ -23,112 +23,144 @@ class EnhancedHttp extends StreamedRequest with Interceptor, Utils {
23
23
Future <dynamic > get (String path,
24
24
{Map <String , String >? headers,
25
25
InterceptorOptions ? interceptors,
26
- String ? responseType}) async {
26
+ String ? responseType,
27
+ Map <String , String >? options}) async {
28
+ final url = Uri .parse ('$baseURL $path ' );
27
29
return await request (() async {
28
- final url = Uri .parse ('$baseURL $path ' );
29
30
if (isStream (headers, responseType)) {
30
- return await streamed ('GET' , url, mergeHeaders (this .headers, headers),
31
+ return await streamed (
32
+ 'GET' ,
33
+ url,
34
+ mergeHeaders (
35
+ this .headers, headers, this .interceptors! .headers? .call ()),
31
36
responseType: responseType);
32
37
}
33
38
return await http.get (
34
39
url,
35
- headers: mergeHeaders (this .headers, headers),
40
+ headers: mergeHeaders (
41
+ this .headers, headers, this .interceptors! .headers? .call ()),
36
42
);
37
- }, interceptors);
43
+ }, url, options, interceptors);
38
44
}
39
45
40
46
Future <dynamic > post (String path,
41
47
{dynamic payload,
42
48
Map <String , String >? headers,
43
49
InterceptorOptions ? interceptors,
44
50
List <dynamic >? files,
45
- String ? responseType}) async {
51
+ String ? responseType,
52
+ Map <String , String >? options}) async {
46
53
final url = Uri .parse ('$baseURL $path ' );
47
54
return await request (() async {
48
55
if (isStream (headers, responseType)) {
49
- return await streamed ('POST' , url, mergeHeaders (this .headers, headers),
50
- payload: payload, files: files, responseType: responseType);
56
+ return await streamed (
57
+ 'POST' ,
58
+ url,
59
+ mergeHeaders (
60
+ this .headers, headers, this .interceptors! .headers? .call ()),
61
+ payload: payload,
62
+ files: files,
63
+ responseType: responseType);
51
64
}
52
65
return await http.post (
53
66
url,
54
- headers: mergeHeaders (this .headers, headers),
67
+ headers: mergeHeaders (
68
+ this .headers, headers, this .interceptors! .headers? .call ()),
55
69
body: payload == null ? {} : jsonEncode (payload),
56
70
);
57
- }, interceptors);
71
+ }, url, options, interceptors);
58
72
}
59
73
60
74
Future <dynamic > _update (String method, String path, payload, headers,
61
- interceptors, files, responseType) async {
75
+ interceptors, files, responseType, options ) async {
62
76
final url = Uri .parse ('$baseURL $path ' );
63
77
return await request (() async {
64
78
if (isStream (headers, responseType)) {
65
- return await streamed (method, url, mergeHeaders (this .headers, headers),
66
- payload: payload, files: files, responseType: responseType);
79
+ return await streamed (
80
+ method,
81
+ url,
82
+ mergeHeaders (
83
+ this .headers, headers, this .interceptors! .headers? .call ()),
84
+ payload: payload,
85
+ files: files,
86
+ responseType: responseType);
67
87
} else {
68
88
payload ?? = {};
69
89
if (method == "PUT" ) {
70
90
return await http.put (
71
91
url,
72
- headers: mergeHeaders (this .headers, headers),
92
+ headers: mergeHeaders (
93
+ this .headers, headers, this .interceptors! .headers? .call ()),
73
94
body: jsonEncode (payload),
74
95
);
75
96
}
76
97
return await http.patch (
77
98
url,
78
- headers: mergeHeaders (this .headers, headers),
99
+ headers: mergeHeaders (
100
+ this .headers, headers, this .interceptors! .headers? .call ()),
79
101
body: jsonEncode (payload),
80
102
);
81
103
}
82
- }, interceptors);
104
+ }, url, options, interceptors);
83
105
}
84
106
85
107
Future <dynamic > put (String path,
86
108
{dynamic payload,
87
109
Map <String , String >? headers,
88
110
InterceptorOptions ? interceptors,
89
111
List <dynamic >? files,
90
- String ? responseType}) async {
91
- return _update (
92
- "PUT" , path, payload, headers, interceptors, files, responseType);
112
+ String ? responseType,
113
+ Map <String , String >? options}) async {
114
+ return _update ("PUT" , path, payload, headers, interceptors, files,
115
+ responseType, options);
93
116
}
94
117
95
118
Future <dynamic > patch (String path,
96
119
{dynamic payload,
97
120
Map <String , String >? headers,
98
121
InterceptorOptions ? interceptors,
99
122
List <dynamic >? files,
100
- String ? responseType}) async {
101
- return _update (
102
- "PATCH" , path, payload, headers, interceptors, files, responseType);
123
+ String ? responseType,
124
+ Map <String , String >? options}) async {
125
+ return _update ("PATCH" , path, payload, headers, interceptors, files,
126
+ responseType, options);
103
127
}
104
128
105
129
Future <dynamic > delete (String path,
106
130
{Map <String , String >? headers,
107
131
InterceptorOptions ? interceptors,
108
- String ? responseType}) async {
132
+ String ? responseType,
133
+ Map <String , String >? options}) async {
134
+ final url = Uri .parse ('$baseURL $path ' );
109
135
return await request (() async {
110
- final url = Uri .parse ('$baseURL $path ' );
111
136
if (isStream (headers, responseType)) {
112
137
return await streamed (
113
- 'DELETE' , url, mergeHeaders (this .headers, headers),
138
+ 'DELETE' ,
139
+ url,
140
+ mergeHeaders (
141
+ this .headers, headers, this .interceptors! .headers? .call ()),
114
142
responseType: responseType);
115
143
}
116
144
return await http.delete (
117
145
url,
118
- headers: mergeHeaders (this .headers, headers),
146
+ headers: mergeHeaders (
147
+ this .headers, headers, this .interceptors! .headers? .call ()),
119
148
);
120
- }, interceptors);
149
+ }, url, options, interceptors);
121
150
}
122
151
123
152
Future <dynamic > head (String path,
124
153
{Map <String , String >? headers,
125
154
InterceptorOptions ? interceptors,
126
- String ? responseType}) async {
155
+ String ? responseType,
156
+ Map <String , String >? options}) async {
157
+ final url = Uri .parse ('$baseURL $path ' );
127
158
return await request (() async {
128
159
return await http.head (
129
- Uri .parse ('$baseURL $path ' ),
130
- headers: mergeHeaders (this .headers, headers),
160
+ url,
161
+ headers: mergeHeaders (
162
+ this .headers, headers, this .interceptors! .headers? .call ()),
131
163
);
132
- }, interceptors);
164
+ }, url, options, interceptors);
133
165
}
134
166
}
0 commit comments