dart-lang / dart-lang/http

Multipart with headers per field

Open
#283 4 comments 4 reactions 0 assignees View on GitHub
Dominant language
Dart
Stars
1.1k
Forks
419
Avg merge
4d 14h
Merged PRs (30d)
8

Description

Currently when using Multipart fields, the headers that are sent for each fields are hard-coded and can't be changed by the caller. I need to be able to change the content-type for a specific field, declaring it as application/json.

I suggest to change the value type of the fields map inside MultipartRequest to a class that will hold the value and the headers, such as this:
```
class MultipartField {
final String value;
final Map headers;

MultipartField(this.value, {this.headers});
}
```

There isn't much left to do after that but to create a headers string from the map.

p.s.
If anyone needs it until the issue is resolved, I personally copied the entire MulttipartRequest file to a new one and made the change. I also had to copy a few functions from the utils.dart page. Not the prettiest solution, but it works.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.