content-type altered
- Dominant language
- JavaScript
- Stars
- 953
- Forks
- 164
- PR merge metrics
- No merged PRs in 30d
Description
Using Unirest, I am trying to upload a PDF file to a third party program. This third party program requires the Content-Type to be set like so: `application/pdf;name=test.pdf` however when I inspect the network traffic I see that Unirest is removing `;name=test.pdf` from the Content-Type so that it is only sent with `application/pdf`. Is there any way to prevent this?
Here is the full code:
```
const unirest = require('unirest');
const fs = require('fs');
const path = require('path');
var Request = unirest.post('http://192.168.1.200:95/Insert');
Request
.attach('remote file', fs.createReadStream(path.join(__dirname, 'test.pdf'))) // Attachment
.headers({
'Content-Type': 'application/pdf;name=test.pdf',
})
.end(function (response) {
console.log(response.body);
});
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the request shown in the issue and inspect how Request.attach() and headers() are serialized into the outgoing multipart request. Trace the request-building path to find where the Content-Type parameter is removed. Done means the outgoing request preserves application/pdf;name=test.pdf and the existing upload behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- api, networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100