libcurl - django error with use curl download CURLOPT_RESUME_FROM_LARGE -
i use django ,just download file server. , use curl download file in client. when add curlopt_resume_from_large resume broken transfer,error come. don't know server error or client error.
client download code:
file* ptmpfile = fopen((m_download_filepath_pre+tmpfilename).c_str(), "ab+"); fseek(ptmpfile, 0l, seek_end); int currentsize = ftell(ptmpfile); curl_easy_setopt(curl, curlopt_file, ptmpfile); curl_easy_setopt(curl, curlopt_header ,0); curl_easy_setopt(curl, curlopt_nobody, 0); curl_easy_setopt(curl, curlopt_connecttimeout,60); curl_easy_setopt(curl, curlopt_noprogress ,0); curl_easy_setopt(curl, curlopt_progressfunction ,my_progress_func); curl_easy_setopt(curl, curlopt_progressdata ,sdownload); curl_easy_setopt(curl, curlopt_resume_from_large, currentsize);
myserver error:
exception happened during processing of request ('127.0.0.1', 50232) traceback (most recent call last): file "/library/frameworks/python.framework/versions/7.3/lib/python2.7/socketserver.py", line 582, in process_request_thread self.finish_request(request, client_address) file "/library/frameworks/python.framework/versions/7.3/lib/python2.7/socketserver.py", line 323, in finish_request self.requesthandlerclass(request, client_address, self) file "/library/frameworks/python.framework/versions/7.3/lib/python2.7/site-packages/django-1.4-py2.7.egg/django/core/servers/basehttp.py", line 139, in __init__ super(wsgirequesthandler, self).__init__(*args, **kwargs) file "/library/frameworks/python.framework/versions/7.3/lib/python2.7/socketserver.py", line 640, in __init__ self.finish() file "/library/frameworks/python.framework/versions/7.3/lib/python2.7/socketserver.py", line 693, in finish self.wfile.flush() file "/library/frameworks/python.framework/versions/7.3/lib/python2.7/socket.py", line 303, in flush self._sock.sendall(view[write_offset:write_offset+buffer_size]) error: [errno 32] broken pipe
thanks~~
fixed :) client error ,curlopt_resume_from_large must curl_off_t parameter.
curl_easy_setopt(curl, curlopt_resume_from_large, (curl_off_t)currentsize);
or use
curl_easy_setopt(curl, curlopt_resume_from, currentsize);
but knows different between curlopt_resume_from_large , curlopt_resume_from?
Comments
Post a Comment