Specifying file mime type for multipart requests using python requests module
- Ngôn ngữ chính
- TypeScript
- Star
- 1.2k
- Fork
- 242
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
I'm unable to specify the mime type of the files sent as part of `multipart/form-data` requests using the python requests module.
I believe the relevant code is here: https://github.com/Kong/httpsnippet/blob/master/src/targets/python/requests/client.ts#L82
I was thinking we could support it by making a change like so:
```javascript
if (p.fileName) {
if (p.mimeType) {
files[p.name] = `('${p.fileName}', open('${p.fileName}', 'rb'), '${p.mimeType}')`;
} else {
// current behaviour
files[p.name] = `open('${p.fileName}', 'rb')`;
}
hasFiles = true;
} else {
payload[p.name] = p.value;
hasPayload = true;
}
```
Hướng dẫn đóng góp
Hướng nghiên cứu
Start in src/targets/python/requests/client.ts around line 82 and inspect how multipart files are assembled for Python requests snippets. Compare the current file handling with the proposed MIME-type behavior, then check nearby tests or target fixtures if present. Done means a file parameter with a MIME type produces the requested multipart tuple while existing file and payload handling remains unchanged.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python, typescript
- Lĩnh vực
- api, tooling
- Loại issue
- Tính năng
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 45/100