curl-library
libcurl.dll memory restriction??
Date: Sat, 22 Jan 2011 14:11:02 +0100
hi guys, i am getting a strange result with libcurl when trying to download
a file... I am loading the library with "LoadLibrary" and it seems to be
that i get a kind of "restriction", all files i want to download only write
1*1000 bytes.
Im checking those numbers from the variables passed to the write-function
"size * nmemb". I have tried several files and all i get are: 1 * 1081, 1 *
1109, 1 * 1002 and so on... nothing above those numbers which translates to
1KB of data.
My write function is writing the bytes correctly but the problem is that if
i have a file that is 1MB in size i will still only get 1KB.
any idea why is that happening?
*note:* im using a scripting language called autohotkey, im not using c/c++
for this little program. The main point is that i am making a wrapper for
it, and up to now everything is working "fine", ex. i can download an html
page without issues (www.cmyip.com, works fine) but it seems to me that it
is because that page is below 1MB, pages that are bigger than 1MB are
downloaded incompletely because of the same issue i guess.
If you want to see the code for those functions (the wrapper itself) i can
provide you, but i think it might be a restriction of the library being
loaded in to memory and thus having a specific memory amount for working...
any way i can override that?
here is how the script lookslike:
#include ..\cURL.ahk
>
> ; --
> if curl_global_init() ; Initialize cURL
> {
> msgbox % "Global Initialization Error"
> ExitApp
> }
>
> curl:=curl_easy_init() ; Create Session.
> if (curl){
> curl_easy_setopt(curl, "CURLOPT_WRITEFUNCTION",
> RegisterCallBack("WriteFile")) ; Callback function.
> curl_easy_setopt(curl, "CURLOPT_WRITEDATA",
> hFile:=curl_CreateFile(a_desktop "\smartgui.zip"))
>
> curl_easy_setopt(curl, "CURLOPT_URL", "
> http://www.autohotkey.com/download/smartgui.zip")
> if res:=curl_easy_perform(curl)
> msgbox % curl_easy_strerror(res) ; If res is not CURLE_OK (zero)
> show a meaningful string for our error.
>
> cURL_Easy_GetInfo(curl, "CURLINFO_SPEED_DOWNLOAD", Var)
> msgbox % var
> }
> curl_easy_cleanup(curl) ; End Session.
> curl_global_cleanup() ; mandatory clean up for global
> exitapp
>
>
; Callback function.
> ; This can be personalized to suit your needs as defined here:
> ; http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTWRITEFUNCTION
> WriteFile(ptr, size, nmemb, userdata){
> static
> msgbox % size*nmemb ; it shows 1109
> curl_WriteFile(userdata, ptr, size*nmemb, wsize)
> msgbox % wsize ; it shows 1109 that means that all bytes were
> written correctly.
> curl_CloseHandle(hFile)
> return
> }
>
-- ΓΝΩΘΙ Σ'ΑΥΤΟΝ *vindicta bonum vita iucundius ipsa* ++++++++++++++++++++++++++++++ -- They who can give up essential liberty to obtain a little temporary safety, deserve neither liberty nor safety.
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-01-22