0

I am creating an iOS app in which I want to test several servers with a HTTP request. The app needs to look at a plist file with all the servers to test and expected end results, then execute the test and return a response code (i.e.: 200, 404, etc)

This information needs to then be saved to a server for later evaluation.

The problem I am having is I am unable to find a good viable way to just test a server. I don't need to download anything or save any content from the server, just test it.

How might some of you go about this? AFNetworking? Reachability? NSURLConnection?

Thanks!

4

2 回答 2

1

You can use NSURLConnection to issue a simple GET request to the server (i.e, http://www.google.com) and check the response code. You have several delegate methods, for successful and failed request.

This can be done using this example https://stackoverflow.com/a/6918832/975959

Issuing a GET request is pretty simple with NSURLConnection. for example, see here

Good luck.

于 2013-06-01T23:54:06.480 回答
1

Reachability checks if the network is reachable or not, it won't get any status codes back. Probably not what you want.

Instead, you probably want to make HEAD requests. They're basically the same thing as GET, only, without a response body. You can use NSURLConnection for this, or AFNetworking (which is a wrapper on top of NSURLConnection).

于 2013-06-02T05:34:50.057 回答