Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- http (adress, type := "application/x-www-form-urlencoded", method := "GET", error_log := false, package := "") {
- if (!RegExMatch(adress, "^http[s]?:\/\/.*\..*$")) {
- return error_log ? "Invalid URL adress (#1)" : false
- } else if (!DllCall("Wininet.dll\InternetGetConnectedState", "Str", 0x20, "Int", 0)) {
- return error_log ? "Not internet connection (#2)" : false
- }
- try {
- http := ComObjCreate("WinHttp.WinHttpRequest.5.1")
- http.Open(method, adress, false)
- http.SetRequestHeader("Referer", adress)
- http.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.110 Safari/537.36 u01-05")
- http.SetRequestHeader("Content-Type", type)
- http.SetRequestHeader("Pragma","no-cache")
- http.Send(package)
- http.WaitForResponse()
- if (!StrLen(http.ResponseText)) {
- return error_log ? "Empty response (#3)" : false
- } else {
- if (http.Status !== 200) {
- return error_log ? http.Status "(" http.StatusText ") (#4)" : false
- } else {
- return http.ResponseText
- }
- }
- } catch e {
- return error_log ? e.message "(#5)" : false
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement