Sending post request multipart form data. Error from some microsoft service “Line length limit 100 exceeded”

依然范特西╮ 提交于 2019-12-05 08:47:20

According to these two github issues:

https://github.com/aspnet/AspNetCore/issues/2939

https://github.com/aspnet/AspNetCore/issues/3724

The issue is caused by a failure to use the correct line endings. I can't tell from your code exactly where the issue is occuring, but it should be fairly straightforward to debug it.

You need to use a proxy - I find Fiddler to be very good. Capture the request from Postman and from your Client and compare them. You may need to drop the whole request into an editor like Notepad++ to be able to view the non-printing characters.

Once you find the issue, it should be straightforward to amend to add or remove \r as appropriate.

The code below setup a HTTP server at localhost:3000, and for all incoming requests, the server dumps the raw request body.

Try posting your request to localhost:3000 from both Postman and Nodejs, and compare the difference.

require('http').createServer((req, res) => {
    req.on("data", _ => _)
       .on("end" , _ => res.end(req.socket.rawBody));
}).on('connection', socket => {
    socket.rawBody = "";
    socket.on('data', data => socket.rawBody += data.toString());
}).listen(3000);

This is the sample output

POST / HTTP/1.1
Authorization: Basic QUJDOkFCQw==
User-Agent: PostmanRuntime/7.15.0
Accept: */*
Cache-Control: no-cache
Host: localhost:3000
accept-encoding: gzip, deflate
content-type: multipart/form-data; boundary=--------------------------540608501697240762060297
content-length: 268
Connection: keep-alive

----------------------------540608501697240762060297
Content-Disposition: form-data; name="Lang"

SV
----------------------------540608501697240762060297
Content-Disposition: form-data; name="Login"

ABC
----------------------------540608501697240762060297--

Hope this will help you debug the problem.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!