Jump to content

Use Proxy with TCPConnect?


 Share

Recommended Posts

Hi everyone.

I have script that i use to connect to webbservice (sending a csv file). It also downloads data rom the internet usi9ng inetget. Everything works fine, except when the program is run behind a proxy.

If i use httpsetproxy i can get inetget function to work. However i cant get my httpget/httppost functions to work. So im looking for suggestions on workarounds or other possabilities?

here is an example code.

#include <winhttp.au3>
#include <md5.au3>

$choise = MsgBox(3,"Välj","Ja = Använd Ingen proxy, Nej = Använd samma inställningar som Internet Explorer, Avbryt = Ange själv.")
if $choise = 7 then HttpSetProxy(0)
if $choise = 2 then
    $string = InputBox("Proxy","Ange hela procy strängen som ska testas")
    HttpSetProxy(2,$string)
EndIf
$keff = InetRead("http://vecka.nu",1)
if $keff <> "" then $keff = "OK"
if $keff = "" then $keff = "FAIL"
MsgBox(0,"Testar InetGet:",$keff)

$resultat = _testwebbservice()
If $resultat = "OK" Then
    MsgBox(0, "OK", "Webbservice svarade: OK.")
Else
    MsgBox(0, "ERROR", "Webbservice svarade: " & $resultat)
EndIf


Func _testwebbservice()
    $adress = "servername.se"
    $path = "/api/uploadcsv"
    $data = "Testar Webbservice!"
    $data_enc = _httpencodestring($data)
    $filename = "testfil.dat"
    $description = _httpencodestring($filename)
    $socket = _httpconnect($adress, 80)
    $hash = _httpencodestring(md5($data & $filename & "hashpassword"))
    _httppost($adress, $path, $socket, "data=" & $data_enc & "&description=" & $description & "&md5sum=" & $hash)
    $answer = _httpread($socket, 0)
    If $answer = "0" Then
        Return "server svarade inte"
    EndIf
    If StringInStr($answer, "error") Then
        $answer = StringStripWS(StringReplace(StringReplace($answer, "{", ""), "}", ""), 8)
        Return $answer
    Else
        Return "OK"
    EndIf
EndFunc
Link to comment
Share on other sites

Have a look at the >AutoProxy UDF.

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

"So im looking for suggestions on workarounds or other possabilities?" You said it yourself :P

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

Where did you get the winhttp.au3 I'm having a hard time finding it. :(

Any chance you remember where you got it from?

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

HttpSetProxy, InetGet and InetRead rely on IE functions... whereas WinHTTP does not. There should be provisions for a proxy in WinHTTP.

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Link to comment
Share on other sites

WinHTTP.au3 can be found in the Winhttp link in >this page.

I did not try it, but this UDF contains a _WinHttpSetDefaultProxyConfiguration function.

Of course, this is for winhttp functions only, not for TCPConnect... Perhaps it may be appropriate.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...