http-status-codes

QtWebkit: How to check HTTP status code?

让人想犯罪 __ 提交于 2019-12-17 19:19:59
问题 I'm writing a thumbnail generator as per an example in the QtWebkit documentation. I would like to avoid screenshots of error pages such as 404 not found or 503 Internal server error . However, the QWebPage::loadFinished() signal is always emitted with ok = true even when the page gives an HTTP error. Is there a way in QtWebkit to check the HTTP status code on a response? 回答1: Turns out you need to monitor the QNetworkAccessManager associated with your QWebPage and wait for a finished(...)

HTTP status code for temporarily unavailable pages

与世无争的帅哥 提交于 2019-12-17 18:31:48
问题 I'm redesigning my small business' website. I will be putting up a temporarily 'under construction' splash page. I know, I know... but it will be one in style, I hope. :) What, mostly for SEO purposes, is the best HTTP status code to dish out for the URLs that will be temporarily unavailable (the same URLs will have content again, after the new site is up). Now, my website traffic is hardly of any importance, but as a webdeveloper I want this knowledge in my toolbox for possible future client

REST: Mapping application errors to HTTP Status codes

别等时光非礼了梦想. 提交于 2019-12-17 17:39:20
问题 Is it to be considered good practice to reuse RFC HTTP Status codes like this, or should we be making up new ones that map exactly to our specific error reasons? We're designing a web service API around a couple of legacy applications. In addition to JSON/XML data structures in the Response Body, we aim to return HTTP Status Codes that make sense to web caches and developers. But how do you go about mapping different classes of errors onto appropriate HTTP Status codes? Everyone on the team

What's the appropriate HTTP status code to return if a user tries logging in with an incorrect username / password, but correct format?

天涯浪子 提交于 2019-12-17 16:26:43
问题 A similar question is posted here: What's an appropriate HTTP status code to return by a REST API service for a validation failure? The answer in the thread above states that "For instance if the URI is supposed to have an ISO-8601 date and you find that it's in the wrong format or refers to February 31st, then you would return an HTTP 400. Ditto if you expect well-formed XML in an entity body and it fails to parse." However, what happens if the user submitted correctly formatted data? By

When is it appropriate to respond with a HTTP 412 error?

对着背影说爱祢 提交于 2019-12-17 16:24:44
问题 It is unclear to me when you should and should not return a HTTP 412: Precondition Failed, error for a web service? I am thinking of using it when validating data. For example, if a client POST's XML data and that data is missing a required data element, then responding with a 412 and a description of the error. Does that align with the spirit of responding with an HTTP 412, or should something else be used (e.g. another http error code or web application exception)? 回答1: If you look at RFC

In Python, how do I use urllib to see if a website is 404 or 200?

狂风中的少年 提交于 2019-12-17 15:20:18
问题 How to get the code of the headers through urllib? 回答1: The getcode() method (Added in python2.6) returns the HTTP status code that was sent with the response, or None if the URL is no HTTP URL. >>> a=urllib.urlopen('http://www.google.com/asdfsf') >>> a.getcode() 404 >>> a=urllib.urlopen('http://www.google.com/') >>> a.getcode() 200 回答2: You can use urllib2 as well: import urllib2 req = urllib2.Request('http://www.python.org/fish.html') try: resp = urllib2.urlopen(req) except urllib2

Is it wrong to return 202 “Accepted” in response to HTTP GET?

China☆狼群 提交于 2019-12-17 10:33:22
问题 I have a set of resources whose representations are lazily created. The computation to construct these representations can take anywhere from a few milliseconds to a few hours, depending on server load, the specific resource, and the phase of the moon. The first GET request received for the resource starts the computation on the server. If the computation completes within a few seconds, the computed representation is returned. Otherwise, a 202 "Accepted" status code is returned, and the

HTTP status code for a partial successful request

和自甴很熟 提交于 2019-12-17 10:33:20
问题 I have an application that sends messages to users. In a post request a XML string is transferred that consists of all the users that should receive that particular message. If any of the users in the list do not exist I give the list of missing users back to the client for further evaluation. Now I'm asking myself what would be the proper status code for the application saying that the request was accepted but there were things that couldn't be done. The problem would be avoided if it weren

HTTP status code for a partial successful request

感情迁移 提交于 2019-12-17 10:33:16
问题 I have an application that sends messages to users. In a post request a XML string is transferred that consists of all the users that should receive that particular message. If any of the users in the list do not exist I give the list of missing users back to the client for further evaluation. Now I'm asking myself what would be the proper status code for the application saying that the request was accepted but there were things that couldn't be done. The problem would be avoided if it weren

HTTP 400 (bad request) for logical error, not malformed request syntax

好久不见. 提交于 2019-12-17 10:25:10
问题 The HTTP/1.1 specification (RFC 2616) has the following to say on the meaning of status code 400, Bad Request (§10.4.1): The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications. There seems to be a general practice among a few HTTP-based APIs these days to use 400 to mean a logical rather than a syntax error with a request. My guess is that APIs are doing this to distinguish between 400 (client-induced) and 500