codeskyblue / codeskyblue/gohttpserver

上传大文件会失败

Open
#118 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
2.8k
Forks
583
PR merge metrics
No merged PRs in 30d

Description

测试代码如下
```
import requests
from requests_toolbelt import MultipartEncoder
fd = open("/tmp/test.file", "rb")
encoder = MultipartEncoder(
{
'file': ('test', fd, 'application/octet-stream')
}
)
headers = {
"Content-Type": encoder.content_type
}
url = "http://testhost:8000/"
print "start"
r = requests.post(url, headers=headers, data=encoder, timeout=10000)
print r.status_code
print r.text
```

随便生成一个大文件文件
```
wuzhuoquan@filvembp:/tmp$ dd if=/dev/zero of=/tmp/test.file bs=1m count=4096
4096+0 records in
4096+0 records out
4294967296 bytes transferred in 4.895685 secs (877296504 bytes/sec)
```

报错如下
```
/usr/bin/python2.7 /Users/wuzhuoquan/PycharmProjects/test_scripts/upload_file.py
start
Traceback (most recent call last):
File "/Users/wuzhuoquan/PycharmProjects/test_scripts/upload_file.py", line 25, in
r = requests.post(url, headers=headers, data=encoder, timeout=10000)
File "/Users/wuzhuoquan/Library/Python/2.7/lib/python/site-packages/requests/api.py", line 119, in post
return request('post', url, data=data, json=json, **kwargs)
File "/Users/wuzhuoquan/Library/Python/2.7/lib/python/site-packages/requests/api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "/Users/wuzhuoquan/Library/Python/2.7/lib/python/site-packages/requests/sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "/Users/wuzhuoquan/Library/Python/2.7/lib/python/site-packages/requests/sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "/Users/wuzhuoquan/Library/Python/2.7/lib/python/site-packages/requests/adapters.py", line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', error(32, 'Broken pipe'))

进程已结束,退出代码 1
```

count=4096 报错,count=4050 不会

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the failure with the provided Python 2.7 requests/MultipartEncoder script, comparing a 4096 MiB file with a 4050 MiB file. Inspect the server's HTTP upload handling; the issue is done when the larger upload completes without a broken-pipe error.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, python
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.