Log in

View Full Version : Check the response code of a request


moret
March 18th, 2010, 04:17 PM
Hello.

I'm trying to make two requests, and I want to check the response code of the second request. However the method GetHttpResponseCode() is always returning the code of the first request here:


http = mc.Http()
http.Reset()
http.Get("http://www.google.com/")
mc.ShowDialogOk("Test", "ResponseCode 1: %d" % http.GetHttpResponseCode(), ))
http.Reset()
http.Get("http://www.google.com/404")
mc.ShowDialogOk("Test", "ResponseCode 2: %d" % http.GetHttpResponseCode(), ))


ResponseCode 1: 200
ResponseCode 2: 200

Is this the expected behaviour, should I do something more to clear the first response code?

moret
March 19th, 2010, 08:50 AM
I think I just answered my own question.

Instead of using
http.reset()
I had it working using
http = mc.Http()

riegersn
March 19th, 2010, 10:40 AM
Reset() was not working for you?

moret
March 22nd, 2010, 08:53 AM
No, it wasn't. I ran more tests to cover the following four scenarios:

Test A, from valid to invalid url, single http object (i.e., using reset only)
Test B, from invalid to valid url, single http object (i.e., using reset only)
Test C, from valid to invalid url, new http objects (i.e., obtaining from mc)
Test D, from invalid to valid url, new http objects (i.e., obtaining from mc)

And found out that only on the first test the http retains the original response code, ignoring the Reset(). The test code is attached, I hope it helps.

riegersn
March 23rd, 2010, 11:19 PM
would be great if you could take all this info and post a new jira bug for us.

http://jira.boxee.tv/

moret
March 24th, 2010, 01:46 PM
Done.

http://jira.boxee.tv/browse/BOXEE-4578

Actually, there was a closed issue about this:

http://jira.boxee.tv/browse/BOXEE-4266

I linked them in the comments. I hope I'm not messing too much with your Jira. 8)

riegersn
March 24th, 2010, 01:55 PM
no thats fine - thank you!