http-status-codes

C# HttpWebRequest.GetResponse - how is StatusCode usage handled for a non-exception vs webexception response?

最后都变了- 提交于 2019-12-12 10:51:05
问题 Can someone help clear up the usage of the "StatusCode" property in HttpWebResponse and WebException? For example it seems that if: a) there is no exception, then the HttpWebResponse will have a StatusCode that could have some values that indicate both: - success (e.g. OK, Accepted etc) - failure (e.g. UseProxy, RequestTimeout etc) b) there is a WebExeption throw, which itself has a response object that again has a StatusCode (which I assume is based on the same HttpStatusCode Enumeration.

ASP.NET MVC3 HttpStatusCodeResult StatusDescription - Specified argument was out of the range of valid values

蹲街弑〆低调 提交于 2019-12-12 10:35:37
问题 For some reason I'm getting an error trying to return new HttpStatusCodeResult(500, statusDescription); In my MVC3 app. It blows up with the error Specified argument was out of the range of valid values. Parameter name: value Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.ArgumentOutOfRangeException: Specified argument

How to globally handle HTTP errors in Grails (status codes 4xx/5xx)?

妖精的绣舞 提交于 2019-12-12 08:47:59
问题 Is there a way in Grails to catch all the possible HTTP errors before they're being sent to the client browser, as to be able to handle the content being sent to the client? I mean all 4xx and 5xx HTTP status codes , not only the 403, 404 and 500 like other have suggested. What I'd like to do is to catch all HTTP errors in the first place, without having to specify them all one by one, then in a second step I would filter (e.g. in an error controller) specific error codes that I would like to

Catching a specific WebException (550)

谁说胖子不能爱 提交于 2019-12-12 08:46:39
问题 Let's say I create and execute a System.Net.FtpWebRequest . I can use catch (WebException ex) {} to catch any web-related exception thrown by this request. But what if I have some logic that I only want to execute when the exception is thrown due to (550) file not found ? What's the best way to do this? I could copy the exception message and test for equality: const string fileNotFoundExceptionMessage = "The remote server returned an error: (550) File unavailable (e.g., file not found, no

HTTP: error during reply after 200 OK status code

本秂侑毒 提交于 2019-12-12 08:28:17
问题 As an HTTP 1.1 server, I reply to a GET request with 200 OK status code, then start sending the data to the client. During this send, an error occurs, and I cannot finish. I cannot send a new status code as a final status code has already been sent. How should I behave to let the client know an error occurred and I cannot continue with this HTTP request? I can think of only one solution: close the socket, but it's not perfect: it breaks the keep-alive feature, and no clear explanation of the

HTTP status code for overloaded server

空扰寡人 提交于 2019-12-12 08:22:09
问题 Some hours my web site's server has too much load. Which HTTP status code should I send to the Googlebot that visits my website? Is " 269 Call Back Later " this suitable for this case, or 503 Service Unavailable or do you have any more suggestions? 回答1: 503 means the service is temporarily unavailable so it is appropriate to use while the server is overloaded. http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html The Wikipedia article defines 269 as the initial response for a request that

426 Status: WebSockets with Node.js

删除回忆录丶 提交于 2019-12-12 03:38:27
问题 Im currently switching my application from using Socket.io to HTML5 WebSockets . I'm assuming that my problem lies within the first couple lines of both the client and server. My browser keeps on replying with a 426 (Upgrade Required) status when I test my app on localhost. Please shed some light on my problem... Server Code "use strict"; var session = require('./chat-session'), serveStatic = require('serve-static'), server = require('http').createServer(), WebSocketServer = require('ws')

Check GetStreamAsync status

淺唱寂寞╮ 提交于 2019-12-12 03:19:07
问题 Grabbing an image via GetStreamAsync , how do I determine status? HttpClient OpenClient = new HttpClient(); Stream firstImageStream = OpenClient.GetStreamAsync("imageUrl.jpg").Result; Sometimes this will give an error (403 or 404 typically) and I simply want to skip processing those results. All I can find says to use the StatusCode property or IsSuccessStatusCode , but those seem to only work on HttpResponseMessage , which is from GetAsync, which does not give me the Stream I need to process

Setting custom HTTP response headers in LiteSpeed with PHP

霸气de小男生 提交于 2019-12-12 01:45:59
问题 I'm trying to set a custom HTTP 1.0 status code in order to return more descriptive error messages via AJAX (using jQuery). In PHP I have something like: header( 'HTTP/1.0 909 Hello World' ); exit; This works as expected on my development environment using Apache 2.2.15 but it does not work on the production webserver running LiteSpeed 5.5. LiteSpeed instead returns a 200 OK . Using this: header( 'HTTP/1.0 404 Hello World' ); exit; Apache returns the 404 with the text above. LiteSpeed

NSHTTPURLRequest header

坚强是说给别人听的谎言 提交于 2019-12-11 14:41:35
问题 I would like to get some information from a website. I have already got the HTML code of the website. However, I would like to get more header information of the website (e.g. http status code) After read the apple library, I found that there are 2 methods which can display those information. However, I can only use one of the methods (has warning), another cannot be used. The following is the code. NSHTTPURLResponse *response = nil; NSError *error = nil; NSData *responseData =