Sign in to follow this  
Followers 0
Hasher

Improving a 'POST' function

11 posts in this topic

Hi

Below is a fucntion I have been working on , It works fine but I am wondering if I can make it faster

Func posting($i,$end,$LandmarkID)
$oMyError = ObjEvent("AutoIt.Error","MyErrFunc") 
Do
$sTestUrl = "http://www.test.com/data.php?action=senddata"
$PostData = "landmark=" & $LandmarkID 
$ResolveTimeout = 5000
$ConnectTimeout = 5000
$SendTimeout = 5000
$ReceiveTimeout = 5000
$oHttpRequest = ObjCreate("MSXML2.ServerXMLHTTP")

$oHttpRequest.Open ("POST", $sTestUrl)
$oHttpRequest.setRequestHeader  ("Content-Type", "application/x-www-form-urlencoded")
$oHttpRequest.setRequestHeader  ("Connection", "Keep-Alive")
$oHttpRequest.Send ($PostData)
if @error then ExitLoop
$oHttpRequest = ""
    $i = $i + 1
Until $i = $end
EndFunc 

Func MyErrFunc() 
     SetError(1) ; something to check for when this function returns 
Endfunc
oÝ÷ Ø-êÞk²¶)z{ayÊ'ç-ÚÛaz}ý±éÝßٮةºW­g¬mçè­ç%¢È§Ø^rçyËb¢t¨ëax%G­+ºÚ"µÍÜ   ÌÍÚÈHHÈLÝBÌÍÛÒ]YÝÙ[
    ÌÍÔÜÝ]JBÛY
L
B

Unfortunatley this is not working Any help or suggestions would be apprecaited


Firefox's secret is the same as Jessica Simpson's: its effortless, glamorous style is the result of — shhh — extensions!

Share this post


Link to post
Share on other sites



Yes, you can probably do it faster.

But, why would you like to send the same data 1000 times to the same server?

Share this post


Link to post
Share on other sites

You probably want to cheek the readyState property...

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

Thanks for your reply Uten ....I only put 1000 in the example to make a point

Dale thanks for your reply , the best I could come up with is :

Func posting($i,$end,$LandmarkID)
$oMyError = ObjEvent("AutoIt.Error","MyErrFunc") 
Do
$sTestUrl = "http://www.test.com/data.php?action=senddata"
$PostData = "landmark=" & $LandmarkID 
$ResolveTimeout = 5000
$ConnectTimeout = 5000
$SendTimeout = 5000
$ReceiveTimeout = 5000
$oHttpRequest = ObjCreate("MSXML2.ServerXMLHTTP")

$oHttpRequest.Open ("POST", $sTestUrl)
$oHttpRequest.setRequestHeader  ("Content-Type", "application/x-www-form-urlencoded")
$oHttpRequest.setRequestHeader  ("Connection", "Keep-Alive")
$oHttpRequest.Send ($PostData)
$k = 0

While  $oHttpRequest.readyState  =  4
    $oHttpRequest.Send ($PostData) 
    $oHttpRequest.waitForResponse(9000)
    $k = $k + 1
    if $k = 1000 then ExitLoop
    Wend
$oHttpRequest = ""
EndFunc

Unfortunatly this still doesnt work without a ".open" which is the most time consuming and heavy use on the server and program. The loop is working but send isnt sending. Also is there anyway I can watch output , Fiddler is not catching it

Any futher pointers anyone can give me ?


Firefox's secret is the same as Jessica Simpson's: its effortless, glamorous style is the result of — shhh — extensions!

Share this post


Link to post
Share on other sites

Could you try to explain what you want to archive. As far as I understand your code is sending the same form (POST) back to the server a 1000 times. And that does not make sense. In my eyes it looks like a brute force DOS attack?

Share this post


Link to post
Share on other sites

Basically this script takes the hourly colated info in a geological database which is held in a excel data sheet and posts the tally in the company server, normaly its about 300 posts ......that takes about 3 -4 minutes but sometimes its higher or lower depending on the office workload. Overall its part of a larger script that logs statical data to the companys intranet . Unfortunatly I dont have access to the intranet source otherwise I could change it to a whole number rather than post after post.

As for the worth of this script so far my workload has been cut to about 2 hours daily......which I plan to improve on ;-)

No I am not doing a DOS attack on anything and if this thread offends anyone we can close it right here.

Hope that answers your question...... on another note I rewrote this function in delphi with threads and it was actually slower than Autoit......could be my crap coding thou ;-)


Firefox's secret is the same as Jessica Simpson's: its effortless, glamorous style is the result of — shhh — extensions!

Share this post


Link to post
Share on other sites

A very good explanation, thank you..:)

I hope you have an appropriate test server so you don't corrupt.

Sounds like there is a serverside or bandwidth limitation. But on the other hand if you do 300 posts in 4 minutes that is a little less than a second on each post. Not very fast, but not to bad either.

Do you have an appropriate test setup? I guess testing against the production server ain't popular. At least the error message from www.test.com suggests that people use another domain..:D

I will PM you a few suggestions a bit later (abusers can go other places to get their code), but don't expect much.

Share this post


Link to post
Share on other sites

Its www.test.com as my companys intranet is not public , we have a testing database which takes a hammering ....mainly from me . Our Inet is crap in Australia ....really an embrassment, we also are in a remote office and our speeds are restricted to 256k :-(


Firefox's secret is the same as Jessica Simpson's: its effortless, glamorous style is the result of — shhh — extensions!

Share this post


Link to post
Share on other sites

My point with www.test.com is that someone actually owns that domain. So maybe use www.test.local in posted code. People tend to just uncritical copy/paste and run scripts to do a test. You can even find scripts doing this automatically.

Being a testdb must be a shitty life..:)

Share this post


Link to post
Share on other sites

Needless to say I love Uten and autoit :)


Firefox's secret is the same as Jessica Simpson's: its effortless, glamorous style is the result of — shhh — extensions!

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  
Followers 0