curl-library
Re: curl-library Digest, Vol 94, Issue 18
Date: Sat, 15 Jun 2013 23:45:18 -0700 (PDT)
STOP
--- On Thu, 6/13/13, curl-library-request_at_cool.haxx.se  wrote:
> From: curl-library-request_at_cool.haxx.se 
> Subject: curl-library Digest, Vol 94, Issue 18
> To: curl-library_at_cool.haxx.se
> Date: Thursday, June 13, 2013, 9:35 AM
> Send curl-library mailing list
> submissions to
>     curl-library_at_cool.haxx.se
> 
> To subscribe or unsubscribe via the World Wide Web, visit
>     http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-library
> or, via email, send a message with subject or body 'help'
> to
>     curl-library-request_at_cool.haxx.se
> 
> You can reach the person managing the list at
>     curl-library-owner_at_cool.haxx.se
> 
> When replying, please edit your Subject line so it is more
> specific
> than "Re: Contents of curl-library digest..."
> 
> 
> Today's Topics:
> 
>    1. CURLOPT_WRITEFUNCTION; Function not
> writing all data to disc
>       file? (Spencer Elliott)
>    2. RE: cURL using axTLS non-blocking (Hu,
> Eric)
> 
> 
> ----------------------------------------------------------------------
> 
> Message: 1
> Date: Thu, 13 Jun 2013 16:05:47 +0100
> From: Spencer Elliott 
> To: 
> Subject: CURLOPT_WRITEFUNCTION; Function not writing all
> data to disc
>     file?
> Message-ID: 
> Content-Type: text/plain; charset="iso-8859-1"
> 
> Dear all,
> 
>  
> 
>  
> 
> I am very new to LibCurl, and am struggling with the
> CURLOPT_WRITEFUNCTION
> function.
> 
> I have included my source code below, but essentially my
> issue is here:
> 
>  
> 
> /*
> 
>                
>                
> printf("\n");
> 
>                
>                
> printf(response.c_str());
> 
>                
>                
> printf("\n");
> 
>                
>                
> LogToDisk(response);
> 
> */
> 
>  
> 
> The function that stores the data to a string seems to print
> the entire
> string out perfectly fine on the console using ?printf?.
> However, when it
> saves to disc file, there is a large amount of text missing.
> Can anyone help
> me understand what I am doing wrong?
> 
>  
> 
> I noticed that there is an extremely long string in the html
> of the page I
> am going to, and this is also where is just stops working?
> 
>  
> 
> Here is an example of the last line where the file stops
> writing and gives
> up (I put the last part in bold), it should continue waaaay
> past this?:
> 
>  
> 
> >
> (None) Become a member of our community t
> o get inside information and prizes!<br>>
> (None) We have 5 other servers up and&nbs
> p;running!<br>>
> (None) Check out the Doom 24/7 Server!<br>>
> (None) Join our Forums at RenCorner.ca!<br>>
> (None) Too Easy? Join the RenCorner Killing&nb
> sp;Floor - Hard Server!<br>>
> (None) Join our Teamspeak 3 at Ts.RenCorner.ca
> !<br>>
> (None) Join our IRC at irc.RenCorner.ca! #RC-K
> F!<br>>
> (None) Become a member&nbs??K?`?T
> 
>  
> 
>  
> 
>  
> 
> size_t write_to_string(void *ptr, size_t size, size_t count,
> void *stream) 
> 
> {
> 
>    
>    ((std::string*)stream)->append((char*)ptr,
> 0, size*count);
> 
>        return size*count;
> 
> }
> 
>  
> 
> void LogToDisc(std::string str)
> 
> {
> 
>        std::ofstream FP;
> 
>    
>    FP.open("temp.txt",std::ios::trunc);
> 
>        FP <<
> StrFormat("%s\n", str.c_str()) << std::endl;
> 
>        FP.close();
> 
>  
> 
>        std::ifstream
> file_in("temp.txt");
> 
>        if(!file_in)
> 
>        {
> 
>              
> printf("Unable to open the text file \"temp.txt\".\n");
> 
>               return;
> 
>        }
> 
> }
> 
>  
> 
>  
> 
> Void myFunction()
> 
> {
> 
>        CURL *curl;
> 
>        CURLcode res;
> 
>        curl = curl_easy_init();
> 
>        if(curl) 
> 
>        {
> 
>               std::string
> response;
> 
>              
> curl_easy_setopt(curl, CURLOPT_URL,
> "http://208.115.205.106:8075/ServerAdmin/current_game");
> 
>              
> curl_easy_setopt(curl, CURLOPT_USERAGENT, "User-Agent:
> Mozilla/5.0 (Windows NT 6.1; WOW64; rv:21.0) Gecko/20100101
> Firefox/21.0");
> 
>              
> curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
> 
>              
> curl_easy_setopt(curl, CURLOPT_POST, 1);
> 
>               char
> data[128];
> 
>              
> sprintf(data, "%s:%s", WebAdminUserName, WebAdminPassword);
> 
>              
> curl_easy_setopt(curl, CURLOPT_USERPWD, data);
> 
>              
> sprintf(data, "UserName=%s&Password=%s",
> WebAdminUserName,
> WebAdminPassword);
> 
>              
> curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
> 
>              
> curl_easy_setopt(curl, CURLOPT_COOKIEJAR, "cookie");
> 
>              
> curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "cookie"); 
> 
>              
> curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,
> write_to_string);
> 
>              
> curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
> 
> res = curl_easy_perform(curl);
> 
>               if(CURLE_OK
> == res) 
> 
>               {
> 
>                
>      char *ct;
> 
>                
>      res = curl_easy_getinfo(curl,
> CURLINFO_CONTENT_TYPE,
> &ct);
> 
>                
>      if((CURLE_OK == res) &&
> ct)
> 
>                
>      {
> 
>                
>            printf("We
> received Content-Type: %s\n", ct);
> 
>                
>      }
> 
>                
>      curl_easy_cleanup(curl);
> 
>               }
> 
>              
> printf("\n");
> 
>              
> printf(response.c_str());
> 
>              
> printf("\n");
> 
>              
> LogToDisk(response); //This is the bit that goes wrong?
> 
>        }
> 
> }
> 
>  
> 
>  
> 
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: 
> 
> ------------------------------
> 
> Message: 2
> Date: Thu, 13 Jun 2013 16:35:10 +0000
> From: "Hu, Eric" 
> To: libcurl development 
> Subject: RE: cURL using axTLS non-blocking
> Message-ID:
>     <058C0A318CE5B443BC188A5193848A50036D65_at_DMPEMPE008.LA.FRD.DIRECTV.com>
> Content-Type: text/plain; charset="us-ascii"
> 
> > Anyway, I've just merged Eric's non-blocking work into
> master now so it'd be
> > great if you (both) could just try that out and see
> that everything looks fine
> > now in axtls land.
> > 
> All tests in the 300-399 range work for me (except 313,
> which is expected to fail).  Some new tests are
> failing, but I don't think it has anything to do with
> axtls.c.  Test 31 and 62 were called out by commit
> f24dc0.  Tests 1300-1309 and 1330 are failing, but
> they're also failing in commit 9b8df5, immediately prior to
> axTLS changes going in.
> 
> Eric
> 
> 
> 
> 
> ------------------------------
> 
> Subject: Digest Footer
> 
> _______________________________________________
> curl-library mailing list
> curl-library_at_cool.haxx.se
> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-library
> 
> 
> ------------------------------
> 
> End of curl-library Digest, Vol 94, Issue 18
> ********************************************
>
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2013-06-16