Checking if a URL is valid via responcecodes
My App gets a lot of URLs back via JSON data.
Some of the URLS have no content (Code 204) and some do (Code 200).
At the moment I get the response code by making a call to the URl and the response code comes back along with all the data at that URL. So it pretty much downloads everything at the URL just so I can check its response code.
Is there a way to make a call to only get the response code and not all t开发者_如何学编程he data? There can be a lot of data sometimes so its slow and a waste of the users data allowance.
Many Thanks, Code
Are you sure you are getting content with 204 status code?
The 204 response MUST NOT include a message-body, and thus is always terminated by the first empty line after the header fields.
For other status codes, consider using HEAD method instead of GET. Off course you can not use HEAD instead of POST, PUT etc. because they are supposed to modify server state so it doesn't make sense to just get metainformation for these methods.
精彩评论