【问题标题】:Curl: HTTP/1.1 100 Continue message on File Upload卷曲:HTTP/1.1 100 文件上传继续消息
【发布时间】:2015-02-22 06:39:09
【问题描述】:

我在我的一个 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 Continue

【问题讨论】:

    标签: python django curl django-file-upload


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-01-07
      • 2011-06-07
      • 2020-04-24
      • 1970-01-01
      • 2012-06-21
      • 2013-03-21
      • 2011-01-16
      • 2017-07-14
      相关资源
      最近更新 更多