Http Timeout does not work for MultiPart request
- Dominant language
- Dart
- Stars
- 1.1k
- Forks
- 419
- Avg merge
- 4d 14h
- Merged PRs (30d)
- 8
Description
Here is my MultiPartRequest code
```
var request =
http.MultipartRequest("POST", Uri.parse(EMPLOYEE_PUNCH_IN_URL));
request.fields['uid'] = userId;
request.fields['location'] = location;
request.fields['punchin_time'] = punchInTime;
request.fields['punchin_location_name'] = address;
var multiPartFile = await http.MultipartFile.fromPath(
"photo", imageFile.path,
contentType: MediaType("image", "$extension"));
request.files.add(multiPartFile);
http.StreamedResponse response = await request.send();
var responseByteArray = await response.stream.toBytes();
employeePunchInModel = standardSerializers.deserializeWith(
EmployeePunchInModel.serializer,
json.decode(utf8.decode(responseByteArray)));
......
```
know how to set timeout to a normal http request. I have followed this link
[https://stackoverflow.com/questions/51487818/set-timeout-for-httpclient-get-request]
I have tried adding timeout function in following ways but it won't work and my request gets completed
1.
```
var multiPartFile = await http.MultipartFile.fromPath(
"photo", imageFile.path,
contentType: MediaType("image", "$extension")).timeout(const Duration(seconds: 1));
```
2.
`http.StreamedResponse response = await request.send().timeout(const Duration(seconds: 1));
`
3.
`var responseByteArray = await response.stream.toBytes().timeout(const Duration(seconds: 15));
`
But none of the above timeout works.
Contributor guide
Assessment
This issue has not been assessed yet.