 |
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% |
[ 23 ] |
| no, i prefer collecting the functions i need |
|
0% |
[ 0 ] |
| neither nor ... explained in post |
|
4% |
[ 1 ] |
|
| Total Votes : 24 |
|
| Author |
Message |
heresy
Joined: 11 Mar 2008 Posts: 291
|
Posted: Sun Jul 27, 2008 11:30 am Post subject: |
|
|
@ skrommel
the weird thing is they returns 404 even it's POSTed successfully. when i removed error handling for 404 temporarily in HttpQuery. i could got the result properly.
just simply add 404 at the line around 183 in httpquery.ahk
if !(InStr("100 200 201 202 302",RetValue)) {
should be
if !(InStr("100 200 201 202 302 404",RetValue)) {
| Code: | httpQuery(Var, "http://pastebin.com/pastebin.php", "poster=HttpQueryTest&format=Python&paste=send&expiry=d&code2=Testing a bit..")
VarSetCapacity(Var, -1)
Gui, Add, Edit, w600 h400 , %Var%
RegExMatch(Var,"<li class=""highlight""><a href=""(.+?)"">",Out)
Gui, Add, Edit, w600, %Out1%
Gui, Show |
_________________ Easy WinAPI - Dive into Windows API World
Benchmark your AutoHotkey skills at PlayAHK.com |
|
| Back to top |
|
 |
DerRaphael
Joined: 23 Nov 2007 Posts: 604 Location: 127.0.0.1
|
Posted: Sun Jul 27, 2008 12:00 pm Post subject: |
|
|
@heresy this patch is not needed i fixed it in the function thus resulting an update to v0.3.3. disabling the 404 handling is IMHO not a good idea.
The Problem as far as i've understood it, was that the httpQuery function tried to access the Header response Location setting which is not accessible at that time (so its a timing problem) introducing the httpQueryDwFlags variable solves this problem (also others such as pages from mozdev) an example how to set this property and use it properly is shown in 1st post as example V.
more updates:
httpQueryReferer [sic] allows custom referrer set
httpQueryAcceptTypes allows custom set accept types for received datastreams.
greets
DerRaphael _________________
|
|
| Back to top |
|
 |
skrommel
Joined: 30 Jul 2004 Posts: 181
|
Posted: Sun Jul 27, 2008 11:59 pm Post subject: |
|
|
Then it wasn't just me... Thanks a million, DerRaphael!
Skrommel _________________ www.1HourSoftware.com |
|
| Back to top |
|
 |
heresy
Joined: 11 Mar 2008 Posts: 291
|
Posted: Mon Jul 28, 2008 9:03 am Post subject: |
|
|
| DerRaphael wrote: | | @heresy this patch is not needed i fixed it in the function thus resulting an update to v0.3.3. disabling the 404 handling is IMHO not a good idea. | dude i never expect that you can solve it without breaking the easy interface well done! _________________ Easy WinAPI - Dive into Windows API World
Benchmark your AutoHotkey skills at PlayAHK.com |
|
| Back to top |
|
 |
AnAHKUser Guest
|
Posted: Wed Jul 30, 2008 7:02 am Post subject: |
|
|
Great work DerRaphael, really inspiring  |
|
| Back to top |
|
 |
y did hob Guest
|
Posted: Thu Jul 31, 2008 6:38 pm Post subject: |
|
|
i am currently having a problem understanding why i cannot get an updated page source when i use this script. i am sure i am missing something but honestly i am still a beginner.
| Code: | #Include httpQuery-0-3-2.ahk
s:
html =
URL = http://watchout4snakes.com/creativitytools/RandomWord/RandomWord.aspx
length := httpQuery(html,URL)
varSetCapacity(html,-1)
StringGetPos,HPos1,html,"randomWord"
HPos1 += 13
StringGetPos,HPos2,html,<,,%HPos1%
Count := HPos2 - HPos1
HPos1 += 1
StringMid,word,html,%HPos1%,%Count%
msgbox,%word%
sleep,5000
goto,s |
my second query is if this is the correct way to set global var for httpquery. this part i am totally unsure. would these need to be set before the include?
| Code: | global httpProxy := 193.146.209.5:80
global httpQueryReferer := "http://www.autohotkey.com" |
|
|
| Back to top |
|
 |
Azerty
Joined: 19 Dec 2006 Posts: 72 Location: France
|
Posted: Fri Aug 01, 2008 8:54 am Post subject: |
|
|
Hi
My suggestions :
1) By default, have an auto-proxy discovery, ie. enable a keyword for global var httpProxy (for instance "auto-discover", have that httpProxy var default to that keyword. This can be achieved by the following way, for instance : read "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" value "ProxyServer"
This would enable running other's submitted httpQuery-based scripts without change (my first tries on your samples won't work due to my Proxomitron usage)
2) add a comment in your code refering to this topic (always useful not to have to remember or add to favorites a topic for each useful script )
3) don't put a version number in the suggested filename for the lib in 1st post, since the published code shouldn't rely on it in #include. To explain further, I made a copy/paste of lib in file "httpQuery-0-3-3.ahk" (as suggested in first post), then copied the xkdc comics sample to a "sample_http.ahk" file in same dir, ran it and... it of course broke since that's an implicit include under "httpQuery.ahk" name... I think as a generic good rule of thumb that lib file names should not include version number, but, of course, the version number must be kept inside the file itself.
You may look at the header of my Ascii85 code for sample of what I mean.
Anyway, very nice and impressive work. Thanks for sharing. Will probably become very popular. _________________ Assembler-coded MCode.ahk ASCII85.ahk library |
|
| Back to top |
|
 |
HugoV
Joined: 27 May 2007 Posts: 650
|
Posted: Fri Aug 01, 2008 10:47 am Post subject: |
|
|
| Azerty wrote: | | ...(my first tries on your samples won't work due to my Proxomitron usage)... | Sorry can't resist to say Hi to a fellow Proxomitron user. I've been using it for a very long time. |
|
| Back to top |
|
 |
ahklerner
Joined: 26 Jun 2006 Posts: 1249 Location: USA
|
Posted: Thu Aug 21, 2008 2:05 am Post subject: |
|
|
| Quote: | | HttpRetCodes...418=I'm a teapot (RFC 2324)... |
no way..
| Quote: | RFC 2324
2.3.2 418 I'm a teapot
Any attempt to brew coffee with a teapot should result in the error
code "418 I'm a teapot". The resulting entity body MAY be short and
stout.
| huh. _________________
ʞɔпɟ əɥʇ ʇɐɥʍ |
|
| Back to top |
|
 |
tank
Joined: 21 Dec 2007 Posts: 1033
|
|
| Back to top |
|
 |
DerRaphael
Joined: 23 Nov 2007 Posts: 604 Location: 127.0.0.1
|
Posted: Sun Sep 07, 2008 10:52 pm Post subject: |
|
|
minor bugfix in version 0.3.4 - sometimes the returned size may differ from updated size via VarSetCapacity(data,-1). The returned size was correct, but the datasize might have had some corrupted data which lead to some strange chars being appended to the variable. this is fixed, as httpQuery sets buffersize greater than needed and prefills the variable with binary zeros.
also fixed the examples just to include httpQuery.ahk not the httpQuery-varVersion.ahk name style.
thanks
and have fun
dR _________________
|
|
| Back to top |
|
 |
hobdiddy Guest
|
Posted: Tue Sep 09, 2008 2:51 am Post subject: |
|
|
| I may be missing something but how would we handle the data that shows up in the "Query String" tab on HttpFox? |
|
| Back to top |
|
 |
DerRaphael
Joined: 23 Nov 2007 Posts: 604 Location: 127.0.0.1
|
Posted: Tue Sep 09, 2008 7:22 pm Post subject: |
|
|
| hobdiddy wrote: | | I may be missing something but how would we handle the data that shows up in the "Query String" tab on HttpFox? |
the data showing up in the query string is the url for httpQuery function.
When clicking on the POST tab and there on the RAW view u'll get a ready to copy POST entry which was actually sent to the target server.
by modifying the data you see there (u'll need to uriEncode your fresh ones) you can use this to send it via autohotkey to the server with a modified content.
greets
dR _________________
|
|
| Back to top |
|
 |
tank
Joined: 21 Dec 2007 Posts: 1033
|
|
| Back to top |
|
 |
Lixx9000 Guest
|
Posted: Mon Sep 22, 2008 8:37 am Post subject: |
|
|
Can't seem to get it to work right.
| Code: | 087: if (Strlen(POSTDATA)>0)
087: {
088: HTTPVerb := POST
089: if StrLen(Headers)=0
090: HEADERS := Content-Type: application/x-www-form-urlencoded
091: }
096: hRequest := DllCall("WinINet\HttpOpenRequestA","uInt",hConnect,"Str",HTTPVerb,"Str",lpszUrlPath . lpszExtrainfo,"Str",ProVer := "HTTP/1.1", "Str",httpQueryReferer,"Str",httpQueryAcceptTypes,"u
103: sRequest := DllCall("WinINet\HttpSendRequestA", "uInt",hRequest,"Str",Headers, "uInt",Strlen(Headers), "Str",POSTData,"uInt",Strlen(POSTData))
107: VarSetCapacity(header, 2048, 0)
108: VarSetCapacity(header_len, 4, 0)
112: Loop,5
113: if ((headerRequest:=DllCall("WinINet\HttpQueryInfoA","uint",hRequest,"uint",21,"uint",&header,"uint",&header_len,"uint",0))=1)
113: if ((headerRequest:=DllCall("WinINet\HttpQueryInfoA","uint",hRequest,"uint",21,"uint",&header,"uint",&header_len,"uint",0))=1)
113: if ((headerRequest:=DllCall("WinINet\HttpQueryInfoA","uint",hRequest,"uint",21,"uint",&header,"uint",&header_len,"uint",0))=1)
113: if ((headerRequest:=DllCall("WinINet\HttpQueryInfoA","uint",hRequest,"uint",21,"uint",&header,"uint",&header_len,"uint",0))=1)
113: if ((headerRequest:=DllCall("WinINet\HttpQueryInfoA","uint",hRequest,"uint",21,"uint",&header,"uint",&header_len,"uint",0))=1)
117: if (headerRequest=1)
125: res := timeout
128: Loop,Parse,res,
,
129: {
130: RetValue := A_LoopField
131: Break
135: if (RetValue="timeout")
135: {
136: html := Error: timeout
137: Return,-1
014: varSetCapacity(html,-1)
016: Gui,Add,Edit,w600 +Wrap r25,html
017: Gui,Show |
|
|
| 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
|