This can GET,POST with SecureLayer,Cookies,User-Agent,Referer,Proxy,Timeout and can disable autoredirect.
Code: Select all
Procedure.s do_request(host.s, page.s="", post_data.s="", cookie.s="", is_secure.b=#False, user_agent.s="", referer.s="", proxy.s="", timeout.l=1000, redirect.b=#True)
If Not proxy="" : access_type.i=3 : Else : access_type.i=1 : EndIf
open_handle = InternetOpen_(user_agent,access_type,proxy,"",0)
InternetSetOption_(open_handle, 2,timeout,4)
If is_secure
port.i=443
flag.l=$00800000|$00001000|$00002000|$00080000|$00000100|$04000000
Else
port.i=80
flag.l=$00080000|$00000100|$04000000
EndIf
If Not redirect : flag|$00200000 : EndIf
If Not post_data="" : verb.s="POST" : Else : verb.s="GET" : EndIf
If page="" : page="/" : EndIf
If user_agent="" : user_agent="Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)" : EndIf
connect_handle = InternetConnect_(open_handle,host,port,"","",3,0,0)
request_handle = HttpOpenRequest_(connect_handle,verb,page,"",referer,0,flag,0)
If verb="POST"
headers.s = "Content-Type: application/x-www-form-urlencoded" +Chr(13)+Chr(10)
HttpAddRequestHeaders_(request_handle,headers,Len(headers), $80000000|$20000000)
EndIf
If Not cookie=""
headers.s = "Cookie: "+cookie+Chr(13)+Chr(10)
HttpAddRequestHeaders_(request_handle,headers,Len(headers), $80000000|$20000000)
EndIf
send_handle = HttpSendRequest_(request_handle,"",0,post_data,Len(post_data))
buffer.s = Space(1024)
Repeat
InternetReadFile_(request_handle,@buffer,1024,@bytes_read.l)
result.s + Left(buffer,bytes_read)
buffer = Space(1024)
Until bytes_read=0
InternetCloseHandle_(open_handle)
InternetCloseHandle_(connect_handle)
InternetCloseHandle_(request_handle)
InternetCloseHandle_(send_handle)
ProcedureReturn result
EndProcedure
Debug do_request("google.com");short call, only GET request for index file on http://google.com
Debug do_request("google.com","/xxx.php","her=vam","vam=her",#True,"Anonym browser 0.1","http://rambler.ru/ref.php","127.0.0.1:8888",2000,#False);full call,
;POST data with cookies,User-Agent:modiffed,referer,proxy,timeout,autoredirect:off to /xxx.php file on https://google.com