vaibhav1312
vaibhav1312

Reputation: 893

Curl: HTTP/1.1 100 Continue message on File Upload

I'm uploading a file using curl in one of my django project, it works fine in localhost, but when I hosted the project in remote server, it does not work.

I'm sending the file from this command

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

and in views.py, I'm handling this file as

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")

This works perfectly fine when i run in local machine, but sending POST request to remote server with curl returns

HTTP/1.1 100 Continue

and do nothing. File is getting uploaded. What should I do.

Thanks

Edit 1: I tried to send some other HttpResponse (file name) from other view method, its working fine, but when i process file, it just sends HTTP/1.1 100 Continue

Upvotes: 3

Views: 2096

Answers (1)

sudo
sudo

Reputation: 5784

I don't know exactly how to fix this in your project, but it looks like your curl is sending the Expect: 100-continue header, prompting the remote server to send back HTTP/1.1 Continue. curl waits to get back that response then uploads the form. You say curl returns the HTTP/1.1 100 Continue then "does nothing," but it should actually be uploading after it receives that, so maybe whatever callback you're using isn't returning that. I would try looking at it with Wireshark.

Upvotes: 1

Related Questions