 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Should a more generic function be released which will include the already available web functions, such as header queries, uri encoding, base encoding, etc ? |
| yes, i'd like to have one function to get all neccessary http functionalities in one instead of collecting each for my own |
|
95% |
[ 95 ] |
| no, i prefer collecting the functions i need |
|
4% |
[ 4 ] |
| neither nor ... explained in post |
|
1% |
[ 1 ] |
|
| Total Votes : 100 |
|
| Author |
Message |
Tuncay
Joined: 07 Nov 2006 Posts: 1886 Location: Germany
|
|
| Back to top |
|
 |
derRaphael
Joined: 23 Nov 2007 Posts: 841 Location: ~/.
|
Posted: Fri Mar 05, 2010 9:45 am Post subject: |
|
|
http://www.opensource.org/licenses/zlib-license.php
| zLib Style Licence wrote: | Copyright (c) 2010 derRaphael & Heresy
This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
- The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
- Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
- This notice may not be removed or altered from any source distribution.
|
_________________
All scripts, unless otherwise noted, are hereby released under CC-BY |
|
| Back to top |
|
 |
Nozavi
Joined: 20 Feb 2008 Posts: 111
|
Posted: Tue Mar 09, 2010 7:27 am Post subject: |
|
|
| Nozavi wrote: | Any ideas on how I can stop my app from crashing because of this error?
 |
Nobody?
DerRaphael? _________________ My scripts: http://apps.nozavi.com |
|
| Back to top |
|
 |
dR* Guest
|
Posted: Tue Mar 09, 2010 8:56 am Post subject: |
|
|
| what exactly are you trying to do? this error msg may be a result from many different possibilities. |
|
| Back to top |
|
 |
Nozavi
Joined: 20 Feb 2008 Posts: 111
|
Posted: Tue Mar 09, 2010 9:45 am Post subject: |
|
|
| dR* wrote: | | what exactly are you trying to do? this error msg may be a result from many different possibilities. |
The app just downloads some wallpapers (see here), but once in a while it crashes with this error (and as you can see here it's quite annoying) _________________ My scripts: http://apps.nozavi.com |
|
| Back to top |
|
 |
Banane as Guest Guest
|
Posted: Tue Mar 09, 2010 1:30 pm Post subject: |
|
|
Two possibilities: The Variable which holds the wallpaper data doesn't get reset and by downloading many wallpapers it slowly gets outside the Maximum Memory Range of Variables, or the data it's loading is bigger than 64 mb.
Your able to set the capacity of variables using: #MaxMem Size in MB |
|
| Back to top |
|
 |
Nozavi
Joined: 20 Feb 2008 Posts: 111
|
Posted: Tue Mar 09, 2010 2:06 pm Post subject: |
|
|
| Banane as Guest wrote: | Two possibilities: The Variable which holds the wallpaper data doesn't get reset and by downloading many wallpapers it slowly gets outside the Maximum Memory Range of Variables, or the data it's loading is bigger than 64 mb.
Your able to set the capacity of variables using: #MaxMem Size in MB |
1. It doesn't download many wallpapers, it downloads them one by one... (the function doesn't make it to the next loop)
2. Impossible. Besides the fact that they're wallpapers, after restarting the app, the wallpaper is downloaded sucessfully...
As I said before, this does not happen every time I run the app or at a specific moment. From what I've noticed, the progress bar usually stops in the middle of a download while the memory starts going up... _________________ My scripts: http://apps.nozavi.com |
|
| Back to top |
|
 |
elbeto Guest
|
Posted: Fri Apr 02, 2010 6:48 pm Post subject: Re: Nice, but |
|
|
Ey buddy, I think you can manipulate the cookies using the http headers...
You can read the header, looking for the set-cookie statements (keep it a variable or file) and then send it to the web using the cookie statement...
This link probably will help you:
http://curl.haxx.se/rfc/cookie_spec.html
Header Examples:
HTTP/1.1 200 OK
Cache-Control: private, no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Expires: Sat, 01 Jan 2000 00:00:00 GMT
P3P: CP="DSP LAW"
Pragma: no-cache
Set-Cookie: reg_fb_ref=http%3A%2F%2Fwww.facebook.com%2F; path=/; domain=.facebook.com
Set-Cookie: test_cookie=1; path=/; domain=.facebook.com
Content-Encoding: gzip
Content-Type: text/html; charset=utf-8
X-Cnection: close
Date: Fri, 02 Apr 2010 17:52:43 GMT
Content-Length: 7924
GET *some url* HTTP/1.1
Host: *some host*
User-Agent: *some agent*
Referer: *some referrer*
Cookie: *Cookie data*
| DerBen wrote: | Ok to start, I really like this..
However I can't seem to figure out how to add a cookies tag to the header.
This is roughly what I need to simulate:
###
GET *some url* HTTP/1.1
Host: *some host*
User-Agent: *some agent*
Referer: *some referrer*
Cookie: *Cookie data*
###
This is the code I'm using:
headers := "Cookie: stuff"
length := httpQuery(data:="",URL,"",headers)
Other values seem to get passed except "Cookies:". So am I missing something? The inserted header doesn't end up on the bottom either, not sure if that would make a difference or not. |
|
|
| Back to top |
|
 |
derRaphael
Joined: 23 Nov 2007 Posts: 841 Location: ~/.
|
Posted: Sat Apr 03, 2010 1:13 pm Post subject: |
|
|
a future version of httpQuery will have native build in cookie support aswell as other features like escape, unescape, mimetypes and multipart postings. for now only the basic capability is supported.
the problem with it is, that by including more features, the known syntax will break since the tweaks needed to incorporate these features will work on a different base. and most of the current code will have to be rewritten.
a major reason for rewriting the code is to make it standard lib compatible and to get rid of the current needed global variables, but use a more friendly http_init( "list of features, list of values" ).
for now these are only plans but i am curious to learn of how the community members who actually use this think about such an enhancement.
greets
dR _________________
All scripts, unless otherwise noted, are hereby released under CC-BY |
|
| Back to top |
|
 |
elbeto Guest
|
Posted: Tue Apr 06, 2010 1:23 pm Post subject: question... |
|
|
hi buddy, Im implementing a simple cookie support, Im writing right now the regular expression to get all the Set-Cookies from the web sever (reading the http header)
Im using something like this:
| Code: |
Result := RegExpReplace(header, "s)Set-Cookie.+?;", "")
|
If I use this sentence, I will get everything except the cookies hehehe, Im not an expert using Reg Exp, there is a way to make a deny? I mean, replace everything except the values that match this pattern?
Thanks for your help
| DerRaphael wrote: | a future version of httpQuery will have native build in cookie support aswell as other features like escape, unescape, mimetypes and multipart postings. for now only the basic capability is supported.
the problem with it is, that by including more features, the known syntax will break since the tweaks needed to incorporate these features will work on a different base. and most of the current code will have to be rewritten.
a major reason for rewriting the code is to make it standard lib compatible and to get rid of the current needed global variables, but use a more friendly http_init( "list of features, list of values" ).
for now these are only plans but i am curious to learn of how the community members who actually use this think about such an enhancement.
greets
dR |
|
|
| Back to top |
|
 |
derRaphael
Joined: 23 Nov 2007 Posts: 841 Location: ~/.
|
Posted: Tue Apr 06, 2010 5:05 pm Post subject: |
|
|
quick and dirty cookie sampler:
| Code: | HeaderData=
(Join`r`n
HTTP/1.1 200 OK
Date: Tue, 06 Apr 2010 16:29:16 GMT
Server: Apache/2.2.15 (Unix) mod_ssl/2.2.15 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4 PHP/5.2.13 mod_perl/2.0.4 Perl/v5.8.8
X-Powered-By: PHP/5.2.13
Set-Cookie: MyName=CookieMonster; path=/
Set-Cookie: SessionData=12345678901234567890123456789012; path=/
Content-Length: 154
Content-Type: text/html; charset=utf-8
)
MsgBox % CookiesFromHeader( HeaderData )
CookiesFromHeader( HeaderData )
{
while ( p := RegExMatch( headerData, "sim)^Set-Cookie:\s*(?P<Crumb>[^;]+);", Cookie, ( p ? p+StrLen(Cookie) : 1 ) ) )
{
Cookies .= ( StrLen( Cookies ) ? " " : "" ) CookieCrumb ";"
}
return "Cookie: " Cookies
} |
the return value of the CookiesFromHeader needs to be inserted as new headerdata for the next httpQuery call, so that the server learns about the cookies.
greets
dR _________________
All scripts, unless otherwise noted, are hereby released under CC-BY |
|
| Back to top |
|
 |
elbeto Guest
|
Posted: Tue Apr 06, 2010 6:51 pm Post subject: thank you very much |
|
|
Thanks my friend... Im using your code like this:
| Code: | #noenv
html := ""
URL := "http://www.google.com"
headers := "Accept-Language: en-us,en;q=0.5"
POST := ""
httpQueryOps := "storeHeader"
length := httpQuery(html,URL,POST, headers)
varSetCapacity(html,-1)
MsgBox % CookiesFromHeader( HttpQueryHeader )
CookiesFromHeader( headerData )
{
while ( p := RegExMatch( headerData, "sim)^Set-Cookie:\s*(?P<Crumb>[^;]+);", Cookie, ( p ? p+StrLen(Cookie) : 1 ) ) )
{
Cookies .= ( StrLen( Cookies ) ? " " : "" ) CookieCrumb ";"
}
return "Cookie: " Cookies
}
#include httpQuery.ahk |
And the result is empty, do you have any idea why?
Thanks for your help...
| DerRaphael wrote: | quick and dirty cookie sampler:
| Code: | HeaderData=
(Join`r`n
HTTP/1.1 200 OK
Date: Tue, 06 Apr 2010 16:29:16 GMT
Server: Apache/2.2.15 (Unix) mod_ssl/2.2.15 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4 PHP/5.2.13 mod_perl/2.0.4 Perl/v5.8.8
X-Powered-By: PHP/5.2.13
Set-Cookie: MyName=CookieMonster; path=/
Set-Cookie: SessionData=12345678901234567890123456789012; path=/
Content-Length: 154
Content-Type: text/html; charset=utf-8
)
MsgBox % CookiesFromHeader( HeaderData )
CookiesFromHeader( HeaderData )
{
while ( p := RegExMatch( headerData, "sim)^Set-Cookie:\s*(?P<Crumb>[^;]+);", Cookie, ( p ? p+StrLen(Cookie) : 1 ) ) )
{
Cookies .= ( StrLen( Cookies ) ? " " : "" ) CookieCrumb ";"
}
return "Cookie: " Cookies
} |
the return value of the CookiesFromHeader needs to be inserted as new headerdata for the next httpQuery call, so that the server learns about the cookies.
greets
dR |
|
|
| Back to top |
|
 |
derRaphael
Joined: 23 Nov 2007 Posts: 841 Location: ~/.
|
Posted: Tue Apr 06, 2010 8:39 pm Post subject: |
|
|
when using the parameter showHeader in addition to storeHeader
the headers give me the following:
| script wrote: | ---------------------------
httpQuery.cookies.ahk
---------------------------
HTTP/1.1 200 OK
Date: Tue, 06 Apr 2010 20:27:11 GMT
Expires: -1
Cache-Control: private, max-age=0
Content-Type: text/html; charset=ISO-8859-1
Server: gws
Transfer-Encoding: chunked
---------------------------
OK
--------------------------- |
by means, google doesn't send any cookies
but you're right. there is missing an paramater in the regex. below is the fixed, tested, and working version:
| Code: | #noenv
URL := "http://salt.autohotkey.com"
httpQueryOps := "storeHeader"
length := httpQuery(html,URL)
MsgBox % CookiesFromHeader( HttpQueryHeader )
CookiesFromHeader( headerData ) {
while ( p := RegExMatch( headerData, "sim`a)^Set-Cookie:\s*(?P<Crumb>[^;]+);", Cookie, ( p ? p+StrLen(Cookie) : 1 ) ) )
Cookies .= ( StrLen( Cookies ) ? " " : "" ) CookieCrumb ";"
return "Cookie: " Cookies
} |
greets
dR _________________
All scripts, unless otherwise noted, are hereby released under CC-BY |
|
| Back to top |
|
 |
elbeto Guest
|
Posted: Wed Apr 07, 2010 7:46 am Post subject: excellent buddy, thank you very much |
|
|
excellent buddy, thank you very much!!!
Its working flawless!!!
| DerRaphael wrote: | when using the parameter showHeader in addition to storeHeader
the headers give me the following:
| script wrote: | ---------------------------
httpQuery.cookies.ahk
---------------------------
HTTP/1.1 200 OK
Date: Tue, 06 Apr 2010 20:27:11 GMT
Expires: -1
Cache-Control: private, max-age=0
Content-Type: text/html; charset=ISO-8859-1
Server: gws
Transfer-Encoding: chunked
---------------------------
OK
--------------------------- |
by means, google doesn't send any cookies
but you're right. there is missing an paramater in the regex. below is the fixed, tested, and working version:
| Code: | #noenv
URL := "http://salt.autohotkey.com"
httpQueryOps := "storeHeader"
length := httpQuery(html,URL)
MsgBox % CookiesFromHeader( HttpQueryHeader )
CookiesFromHeader( headerData ) {
while ( p := RegExMatch( headerData, "sim`a)^Set-Cookie:\s*(?P<Crumb>[^;]+);", Cookie, ( p ? p+StrLen(Cookie) : 1 ) ) )
Cookies .= ( StrLen( Cookies ) ? " " : "" ) CookieCrumb ";"
return "Cookie: " Cookies
} |
greets
dR |
|
|
| Back to top |
|
 |
Desi Guest
|
Posted: Mon Apr 12, 2010 4:41 pm Post subject: have you implemented this function with threads? |
|
|
DerRaphael your function is amazing, Have you implemented this function with threads? if you did it, can you give me an example? another question is, how you can manage the private proxies? (the one with username and password)
Thank you very much |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|