卷曲:HTTP / 1.1 100继续文件上载消息

时间:2014-12-24 05:21:29

标签: python django curl django-file-upload

我在我的django项目中使用curl上传文件,它在localhost中工作正常,但是当我在远程服务器中托管项目时,它不起作用。

我从此命令发送文件

curl -i --form docfile=@/path_to_file http://example.com/process-file

在views.py中,我将此文件视为

def process_file(request):
    if request.method != 'POST':
        return HttpResponseNotAllowed('Only POST Method')

    docfile = request.FILES['docfile']

    output = main(0, docfile) # output is json object
    return HttpResponse(output,content_type = "application/json")

当我在本地计算机上运行时,这非常正常,但是使用curl返回

将POST请求发送到远程服务器
HTTP/1.1 100 Continue

什么都不做。文件正在上传。我该怎么办。

谢谢

编辑1: 我尝试从其他视图方法发送一些其他HttpResponse(文件名),它工作正常,但是当我处理文件时,它只发送HTTP / 1.1 100继续

1 个答案:

答案 0 :(得分:1)

我不确切知道如何在您的项目中解决此问题,但看起来curl正在发送Expect: 100-continue标头,提示远程服务器发回{{1} }。 HTTP/1.1 Continue等待返回该响应,然后上传表单。你说curl会返回curl然后"什么都不做,"但实际上它应该在收到之后上传,所以也许你使用的任何回调都不会返回。我会尝试用Wireshark查看它。