[Gambas-user] Web application - CURL and Cookies?

birchy pokerbirch at ...1601...
Tue Dec 30 22:47:17 CET 2008



Rob Kudla wrote:
> Gambas (specifically gb.net.curl) uses libcurl.
Excellent. Regarding cookie handling, gb.net.curl has HttpClient.CookieFile
which allows you to define a file for cookies. According to the libcurl
tutorial  http://curl.netmirror.org/libcurl/c/libcurl-tutorial.html here 
('Cookies Without Chocolate Chips'...near the bottom), it says:

(libcurl tutorial wrote:
> The CURLOPT_COOKIEFILE option also automatically enables the cookie parser
> in libcurl. Until the cookie parser is enabled, libcurl will not parse or
> understand incoming cookies and they will just be ignored. However, when
> the parser is enabled the cookies will be understood and the cookies will
> be kept in memory and used properly in subsequent requests when the same
> handle is used. Many times this is enough, and you may not have to save
> the cookies to disk at all. Note that the file you specify to
> CURLOPT_COOKIEFILE doesn't have to exist to enable the parser, so a common
> way to just enable the parser and not read able might be to use a file
> name you know doesn't exist.
I assume that gb.net.curl uses this same behaviour? If so, simply setting
ANY value for HttpClient.CookieFile() should enable automatic cookie
handling? If this is the case, perhaps an attribute such as
HttpClient.AutomateCookies(boolean) could be added in order to remove the
need for manual cookie handling? It does the same thing as setting
HttpClient.CookieFile() but just makes it much easier to understand. Most of
the time, the end user is not actually interested in the cookie data
itself...all he or she wants is to maintain a login session by sending the
correct cookies.
Perhaps a similar automation could be added for handling gzip as well?
Again, it's an unnecessary manual job that could be turned into a one liner:
HttpClient.AutomateGzip(boolean). All it requires is adding the
'Accept-Encoding: gzip' header to every request and then decompress the
response if the 'Content-Encoding: gzip' header is present.


Rob Kudla wrote:
> you could try using gb.xml. Unfortunately, that seems to be undocumented
> right now.
As discussed previously in this thread 
http://www.nabble.com/Re%3A-Web-application---CURL-and-Cookies--p20793152.html
here , gb.xml does expose the html parsing element of libxml, however the
results are extremely poor.

I guess that manual parsing with string functions is the only accurate way
to achieve this.
-- 
View this message in context: http://www.nabble.com/Web-application---CURL-and-Cookies--tp20435022p21223619.html
Sent from the gambas-user mailing list archive at Nabble.com.





More information about the User mailing list