http-status-codes

Difference between HTTP redirect codes

…衆ロ難τιáo~ 提交于 2019-11-27 02:27:29
The differences between the various HTTP 3XX redirect codes are not clear to me. Yes, I've read the spec, but there seems to be some discrepancy between the standard and actual practice here. The 301 redirect code seems clear enough: This means the resource was permanently moved to another URI, and future requests should use that URI. And the 307 redirect code also seems clear: it means the redirect is temporary, and future requests should still use the original URI. But I can't tell what the difference is between 302 and 303 , or why either of them are really different from 301 . It seems

curl and ping - how to check whether a website is either up or down?

烈酒焚心 提交于 2019-11-27 01:49:17
I want to check whether a website is up or down at a particular instance using PHP. I came to know that curl will fetch the contents of the file but I don't want to read the content of the website. I just want to check the status of the website. Is there any way to check the status of the site? Can we use ping to check the status? It is sufficient for me to get the status signals like (404, 403, etc) from the server. A small snippet of code might help me a lot. something like this should work $url = 'yoururl'; $ch = curl_init($url); curl_setopt($ch, CURLOPT_NOBODY, true); curl_setopt($ch,

Scrapy and response status code: how to check against it?

你离开我真会死。 提交于 2019-11-27 01:37:25
问题 I'm using scrapy to crawl my sitemap, to check for 404, 302 and 200 pages. But i can't seem to be able to get the response code. This is my code so far: from scrapy.contrib.spiders import SitemapSpider class TothegoSitemapHomesSpider(SitemapSpider): name ='tothego_homes_spider' ## robe che ci servono per tothego ## sitemap_urls = [] ok_log_file = '/opt/Workspace/myapp/crawler/valid_output/ok_homes' bad_log_file = '/opt/Workspace/myapp/crawler/bad_homes' fourohfour = '/opt/Workspace/myapp

How to send a status code in PHP, without maintaining an array of status names?

荒凉一梦 提交于 2019-11-27 01:17:47
All I want to do, is send a 404 status code from PHP - but in a generic fashion. Both Router::statusCode(404) and Router::statusCode(403) should work, as well as any other valid HTTP status code. I do know, that you can specify a status code as third parameter to header . Sadly this only works if you specify a string . Thus calling header('', false, 404) does not work. Furthermore I know, that one can send a status code via a header call with a status line: header('HTTP/1.1 404 Not Found') But to do this I have to maintain an array of reason phrases ( Not Found ) for all status codes ( 404 ).

Http Status Code in Android Volley when error.networkResponse is null

依然范特西╮ 提交于 2019-11-27 00:05:23
I am using Google Volley on the Android platform. I am having a problem in which the error parameter in onErrorResponse is returning a null networkResponse For the RESTful API I am using, I need to determine the Http Status Code which is often arriving as 401 (SC_UNAUTHORIZED) or 500 (SC_INTERNAL_SERVER_ERROR), and I can occasionally check via: final int httpStatusCode = error.networkResponse.statusCode; if(networkResponse == HttpStatus.SC_UNAUTHORIZED) { // Http status code 401: Unauthorized. } This throws a NullPointerException because networkResponse is null. How can I determine the Http

HTTP status code 0 - Error Domain=NSURLErrorDomain?

。_饼干妹妹 提交于 2019-11-26 22:05:24
I am working on an iOS project. In this application, I am downloading images from the server. Problem: While downloading images I am getting Request Timeout . According to documentation HTTP status code of request timeout is 408 . But in my application, I am getting HTTP status code 0 with the following error Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo=0xb9af710 {NSErrorFailingURLStringKey= http://xxxx.com/resources/p/PNG/1383906967_5621_63.jpg , NSErrorFailingURLKey= http://xxxx.com/resources/p/PNG/1383906967_5621_63.jpg , NSLocalizedDescription=The request

How to get HTTP status code of <img> tags

◇◆丶佛笑我妖孽 提交于 2019-11-26 22:01:55
问题 I have a page with a lot of images that are generated server-side depending on user actions. And when image loads successfully I'm happy, but when there is an error on the server I have to act according to what an error occurred. For example: 500 code: do this stuff. 503 code: do that stuff and so on. So, my question : is there any way to get status code within "img" tag on-error event handler? 回答1: No, there is no way to get the HTTP status from a request made by an img tag in JavaScript.

How do I get the HTTP status code with jQuery?

a 夏天 提交于 2019-11-26 21:57:46
I want to check if a page returns the status code 401. Is this possible? Here is my try, but it only returns 0. $.ajax({ url: "http://my-ip/test/test.php", data: {}, complete: function(xhr, statusText){ alert(xhr.status); } }); Ravi Mittal this is possible with jQuery $.ajax() method $.ajax(serverUrl, { type: OutageViewModel.Id() == 0 ? "POST" : "PUT", data: dataToSave, statusCode: { 200: function (response) { alert('1'); AfterSavedAll(); }, 201: function (response) { alert('1'); AfterSavedAll(); }, 400: function (response) { alert('1'); bootbox.alert('<span style="color:Red;">Error While

Android: How get the status-code of an HttpClient request

白昼怎懂夜的黑 提交于 2019-11-26 21:41:36
I want to download a file and need to check the response status code (ie HTTP /1.1 200 OK ). This is a snipped of my code: HttpGet httpRequest = new HttpGet(myUri); HttpEntity httpEntity = null; HttpClient httpclient = new DefaultHttpClient(); HttpResponse response = httpclient.execute(httpRequest); ... How do i get the status-code of the response? Robby Pond This will return the int value: response.getStatusLine().getStatusCode() if (response.getStatusLine().getStatusCode()== HttpsURLConnection.HTTP_OK){ ... } 来源: https://stackoverflow.com/questions/2592843/android-how-get-the-status-code-of

Set Response Status Code [duplicate]

感情迁移 提交于 2019-11-26 19:57:37
This question already has an answer here: PHP: How to send HTTP response code? 8 answers I have an API call for which I need to be able to run some checks and potentially return various status codes. I don't need custom views or anything, I just need to return the proper code. If the user hasn't passed proper credentials, I need to return a 401 status. If they haven't sent a supported request format, I need to return a 400 status. Because it's an API, all I really want to do is set the response status and exit with a simple, stupid message about why the request failed (probably using a exit ).