Jump to content
Sign in to follow this  
Tjalve

Use Proxy with TCPConnect?

Recommended Posts

Tjalve

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

Share this post


Link to post
Share on other sites
MikahS

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

 

Share this post


Link to post
Share on other sites
Tjalve

Have a look at the >AutoProxy UDF.

Im sorry, but i dont see how that helps me? 

Share this post


Link to post
Share on other sites
MikahS

"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

 

Share this post


Link to post
Share on other sites
Tjalve

I just dont see how it helps me? :P

Share this post


Link to post
Share on other sites
MikahS

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

 

Share this post


Link to post
Share on other sites
ripdad

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

Share this post


Link to post
Share on other sites
jguinch

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.

Share this post


Link to post
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
Sign in to follow this  

×