Archived Forum Post

Index of archived forum posts

Question:

http.QuickGetStr possible error conditions

Dec 04 '12 at 13:22

I was just wondering was qualifies as an error condition with http.QuickGetStr?

I could also rephrase my question slightly: If I make a request that returns a 404 NOT FOUND, then the request fails. I suppose you could argue that this qualifies as an error condition, but what if I use it simply to test for existence of record of some sort. In that case I want to know that the 404 was returned, but the request was received and understood by the server.

I know that may by approaching this in a bad way, and that the solution should be to not return a 404, but e.g. a 204 or similar instead. In know that using the 404 on purpose is dangerous, because I would be able to tell if the 404 was returned on purpose or because I requested an invalid URL.


Answer

If the HTTP request is successfully sent, and the response is successfully received, even if a 404 response, then it is deemed a success. Your app can check the http.LastStatus method to get the HTTP response status code (such as 200, 204, 404, etc.).