AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[function] httpQuery GET and POST requests - update 0.3.6
Goto page Previous  1, 2, 3 ... 10, 11, 12 ... 14, 15, 16  Next
 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
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%  [ 95 ]
no, i prefer collecting the functions i need
4%
 4%  [ 4 ]
neither nor ... explained in post
1%
 1%  [ 1 ]
Total Votes : 100

Author Message
elbeto



Joined: 11 Apr 2010
Posts: 23

PostPosted: Sat Apr 17, 2010 6:44 am    Post subject: Reply with quote

Desi you can use Autohotkey.dll, HotkeyIt has an Ansi Version that will run the httpquery function without problems and with threads support
Back to top
View user's profile Send private message
CuriousOne
Guest





PostPosted: Sun Apr 18, 2010 8:44 pm    Post subject: Reply with quote

Any way to make this work with AHK_L? (Latest httpQuery Version, tested with Downloader Example)
Back to top
derRaphael



Joined: 23 Nov 2007
Posts: 841
Location: ~/.

PostPosted: Mon Apr 19, 2010 6:24 am    Post subject: Reply with quote

here, Lexikos and HotKeyIt introduced the neccessary modifications to have a version capable of working in virtually any ahk build.

http://www.autohotkey.com/forum/viewtopic.php?p=347068#347068

dR
_________________

    All scripts, unless otherwise noted, are hereby released under CC-BY
Back to top
View user's profile Send private message
elbeto



Joined: 11 Apr 2010
Posts: 23

PostPosted: Sun Apr 25, 2010 2:01 pm    Post subject: http header missing Reply with quote

Hello buddy I check the code below on Windows XP and 7. The httheader is missing...

Code:

#noenv
Gui, Add, Button, x0 y0 w100 h40 gbtnStart, Start Now!
Gui,Show
Return


btnStart:
      fbLogin()
         
fbLogin(){
   HTTPQueryOps := "storeHeader"
   length := HttpQuery(raw, "http://www.google.com")
   varSetCapacity(raw,-1)
   ;FileAppend, %html%.`n, %A_ScriptDir%\facebook.txt
   MsgBox % HttpQueryHeader
}
#Include, httpQuery.ahk


The last message box is empty... If I remove the function works perfect. Do you have any idea of what's happening? I try with google and facebook and the same error.

Thanks for your suggestions
Back to top
View user's profile Send private message
HotKeyIt



Joined: 18 Jun 2008
Posts: 4653
Location: AHK Forum

PostPosted: Sun Apr 25, 2010 5:50 pm    Post subject: Reply with quote

Because function is not global it does not work:
Code:
;...
fbLogin(){
   global
   HTTPQueryOps := "storeHeader"
;...

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun Wink
Back to top
View user's profile Send private message
elbeto



Joined: 11 Apr 2010
Posts: 23

PostPosted: Sun Apr 25, 2010 5:51 pm    Post subject: thanks buddy! Reply with quote

thanks buddy Razz
Back to top
View user's profile Send private message
tov
Guest





PostPosted: Tue May 18, 2010 9:18 am    Post subject: Reply with quote

I'm looking to download a file from an FTP Server (with a progress bar) and then delete the file once the download has completed.

Can anyone help me with this ?

Thanks

tovlesk
Back to top
flashkid



Joined: 25 Aug 2007
Posts: 110

PostPosted: Wed May 26, 2010 10:52 pm    Post subject: Reply with quote

Code:
   ; Get any missing default Values
   defaultOps =
   (LTrim Join|
      httpAgent=AutoHotkeyScript|httpProxy=0|httpProxyByPass=0|INTERNET_FLAG_SECURE=0x00800000
      SECURITY_FLAG_IGNORE_UNKNOWN_CA=0x00000100|SECURITY_FLAG_IGNORE_CERT_CN_INVALID=0x00001000
      SECURITY_FLAG_IGNORE_CERT_DATE_INVALID=0x00002000|SECURITY_FLAG_IGNORE_CERT_WRONG_USAGE=0x00000200
      INTERNET_OPEN_TYPE_PROXY=3|INTERNET_OPEN_TYPE_DIRECT=1|INTERNET_SERVICE_HTTP=3
   )

At a user's of my scripts computer does this code does not work.
I have to use
Code:
   ; Get any missing default Values
   defaultOps =
   (LTrim Join|
      httpAgent=AutoHotkeyScript|httpProxy=0|httpProxyByPass=0|INTERNET_FLAG_SECURE=0x00800000
      SECURITY_FLAG_IGNORE_UNKNOWN_CA=0x00000100|SECURITY_FLAG_IGNORE_CERT_CN_INVALID=0x00001000
      SECURITY_FLAG_IGNORE_CERT_DATE_INVALID=0x00002000|SECURITY_FLAG_IGNORE_CERT_WRONG_USAGE=0x00000200
      INTERNET_OPEN_TYPE_PROXY=3|INTERNET_OPEN_TYPE_DIRECT=0|INTERNET_SERVICE_HTTP=3
   )
then it does.

With UrlDownloadToFile it does work very well, but I don't want to get these temporary files Smile

Why must I change this option? I've searched a bit on google and found out, that there are four values for the "dwAccessType" in "InternetOpen":
    INTERNET_OPEN_TYPE_DIRECT: Resolves all host names locally.
    INTERNET_OPEN_TYPE_PRECONFIG: Retrieves the proxy or direct configuration from the registry.
    INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY: Retrieves the proxy or direct configuration from the registry and prevents the use of a startup Microsoft JScript or Internet Setup (INS) file.
    INTERNET_OPEN_TYPE_PROXY: Passes requests to the proxy unless a proxy bypass list is supplied and the name to be resolved bypasses the proxy. In this case, the function uses INTERNET_OPEN_TYPE_DIRECT.

So httpQuery passes a number from 0 to 3 to the DllCall in InternetOpenA.
Why does it only work with number 0?

PS: He uses a proxy, which is because he has an umts surf stick.

Greetings, flashkid
Back to top
View user's profile Send private message
derRaphael



Joined: 23 Nov 2007
Posts: 841
Location: ~/.

PostPosted: Thu May 27, 2010 4:14 pm    Post subject: Reply with quote

by defining INTERNET_OPEN_TYPE_DIRECT := 0 you actually re-define the connection initialisation to use a preconfigured (eg from registry) setup.

Code:
; snippet from http://www.digitalmars.com/d/archives/digitalmars/D/14913.html

# static DWORD INTERNET_OPEN_TYPE_PRECONFIG                    = 0;
# static DWORD INTERNET_OPEN_TYPE_DIRECT                       = 1;
# static DWORD INTERNET_OPEN_TYPE_PROXY                        = 3;
# static DWORD INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY  = 4;


by the time i wrote the script, it appeared to me as a good idea to "force" a direct connection or to manually set a proxy, and to avoid the default windows settings. a computer might get infected by a malicious piece of software and therefor the internal setup of how to connect to the net might become corrupted. some worms and virii actually do that either to either redirect the target user to a 3rd party website or to avoid updating or downloading anti virus software. this could also be used to spy passwords / login credentials and then redirect the user to the actual target page

so if a proxy is used it should be named explicitly for httpQuery.

i assume that UrlDownloadToFile uses the default setup from windows in any case (eg INTERNET_OPEN_TYPE_PRECONFIG), this might be an idea why it's working.

greets
derRaphael
_________________

    All scripts, unless otherwise noted, are hereby released under CC-BY
Back to top
View user's profile Send private message
flashkid



Joined: 25 Aug 2007
Posts: 110

PostPosted: Thu May 27, 2010 4:22 pm    Post subject: Reply with quote

Thanks for your fast reply Smile

What would you recommend me? I don't know the users proxy configurations, so I should set Internet_Open_Type to preconfig, shouldn't I?
Must I change it in the header of the function or can I declare it from outside like user agent?
Back to top
View user's profile Send private message
gahks n-l-i
Guest





PostPosted: Mon Jun 14, 2010 11:46 am    Post subject: Reply with quote

Hey!

First of all, thanks for this great function, I use it every day, and it's been working great.
But I've been experiencing a small inconvenience since I've started using the function:

My CPU load gets really high for a few (5-10) seconds, I can't even stop AHK until after the function completed.
I wonder if anyone experienced anything like this?

The problem occurs when calling HttpSendRequestA:

Code:
sRequest := DllCall("WinINet\HttpSendRequestA"
                  , "uInt",hRequest,"Str","", "uInt",0
                  , "Str","","uInt",0)


And right after the dllcall finished, the CPU usage falls back to normal.

I don't really know if this is OS/wininet version-specific but I'd really like to solve this, it's bugging the hell out of me.

Here are the specifications of the environment in which I experience the problem:
httpQuery version:
0.3.4
0.3.5

Win version:
Microsoft Windows XP Professional
5.1.2600 Service Pack 2 build 2600

CPU:
x86 Family 15 Model 2 Stepping 7 GenuineIntel ~2205 Mhz

Wininet:
wininet.dll
7.0.6000.20696
806 kB
C:\WINDOWS\system32
Microsoft Corporation

Cheers
gahks
Back to top
Sergio



Joined: 16 Mar 2008
Posts: 160
Location: Brooklyn

PostPosted: Tue Jun 15, 2010 10:31 pm    Post subject: Help! Reply with quote

I hate to do this, but I need help. I've read through the entire thread several times & I've searched everywhere for a working example of this, but I can't find it.

Whenever I run it, I do get it to download information but it's not any different from what URLDownloadToFile would give me. Even with the authentication filled in. Is there a tutorial or a place to start?
_________________
Back to top
View user's profile Send private message
IsNull



Joined: 10 May 2007
Posts: 593
Location: .switzerland

PostPosted: Wed Jun 16, 2010 5:16 am    Post subject: Reply with quote

On the initial Page are some Examples - also there are Examples how to login, save the cookie and hold the session. Search this Thread Wink

Otherwise, post your code, and we may fix it.
_________________
http://securityvision.ch
AHK 2D GAME ENGINE
Back to top
View user's profile Send private message Visit poster's website
Sergio



Joined: 16 Mar 2008
Posts: 160
Location: Brooklyn

PostPosted: Mon Jul 19, 2010 11:20 pm    Post subject: Reply with quote

IsNull wrote:
Otherwise, post your code, and we may fix it.

It wasn't for lack of effort, but I am still stuck... I did use an example from the main page. I changed the Postdata as suggested in Page 2. It does return some data, however it does not accept the authentication. So rather than displaying an e-mail address, it says "EMAIL: Show Email".

Any thoughts on what I might be doing wrong?

Code:
username = "My Login name here"
password  = "My Password here"
#noenv
html     := ""
URL      := "http://www.exporters.sg/member_profile.asp?co_id=7090"
POSTData := "username=" . username . "password=" . password
length := httpQuery(html,URL,POSTdata)
varSetCapacity(html,-1)

Gui,Add,Edit,w800 +Wrap r25,% html
Gui,Show

_________________
Back to top
View user's profile Send private message
derRaphael



Joined: 23 Nov 2007
Posts: 841
Location: ~/.

PostPosted: Mon Jul 19, 2010 11:34 pm    Post subject: Reply with quote

without checking for cookies the page requires more than just username and password, since u cannot know which variables are actually evaluated on serverside you'd need to send all available variables from the given login form. also i guess that cookies will be used so you'll need a cookie function aswell

take a closer look at the source lines from 196 to 251 at source:http://www.exporters.sg/members/memberlogin_form.asp?referer=/membersdir.asp?

also i'd advise you to use install httpFox for firefox and trace the login procedure. this will reveal all neccessary data including cookies.

greets
dR
_________________

    All scripts, unless otherwise noted, are hereby released under CC-BY
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3 ... 10, 11, 12 ... 14, 15, 16  Next
Page 11 of 16

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group