http-status-codes

HTTP status code for limited collection?

血红的双手。 提交于 2020-01-01 10:04:12
问题 I have a restful service where one of the collections is limited (for UX reasons). In this case it has a cap of 25 items. If that is exceeded resources must be deleted before more can be added. As an example if a client submits: POST http://somesite.com/api/v2/stuff {"cool":"stuff"} and there are < 25 things in stuff: 200 OK if > 25 things in stuff: ??? DELETE http://somesite.com/api/v2/stuff/:id POST http://somesite.com/api/v2/stuff {"cool":"stuff"} 200 OK What is the best code for this?

How do I use Fiddler to modify the status code in an HTTP response?

余生颓废 提交于 2019-12-31 08:03:13
问题 I need to test some client application code I've written to test its' handling of various status codes returned in an HTTP response from a web server. I have Fiddler 2 (Web Debugging Proxy) installed and I believe there's a way to modify responses using this application, but I'm struggling to find out how. This would be the most convenient way, as it would allow me to leave both client and server code unmodified. Can anyone assist as I'd like to intercept the HTTP response being sent from

What HTTP Status code to use when a dependency/downstream (like a 3rd party API) fails?

非 Y 不嫁゛ 提交于 2019-12-31 03:04:46
问题 We have a route in our API which (when called) hits another 3rd party API. e.g. HTTP-GET /account/1 this returns some data from our database AND from .. say .. a 3rd party api like Auth0/Okta/SalesForce/whatever. Now, if this 3rd party api call fails for any reason (fails == 4**, 5** or even a 200 OK but the content is some error message) then what error status code should I pass back to the client calling my API? Initially I was thinking an HTTP-500-Server-Error but ... I'm not so sure now

What HTTP Status code to use when a dependency/downstream (like a 3rd party API) fails?

六月ゝ 毕业季﹏ 提交于 2019-12-31 03:04:20
问题 We have a route in our API which (when called) hits another 3rd party API. e.g. HTTP-GET /account/1 this returns some data from our database AND from .. say .. a 3rd party api like Auth0/Okta/SalesForce/whatever. Now, if this 3rd party api call fails for any reason (fails == 4**, 5** or even a 200 OK but the content is some error message) then what error status code should I pass back to the client calling my API? Initially I was thinking an HTTP-500-Server-Error but ... I'm not so sure now

Still necessary to use 'Status: 404 Not Found' for FCGI?

淺唱寂寞╮ 提交于 2019-12-30 09:43:39
问题 Usually, when sending a http status header from PHP, one would send the HTTP header like this: header("HTTP/1.0 404 Not Found"); However, the PHP manual says that for FCGI hosts, one would need to send a "Status" header that is then converted into a HTTP header by the FCGI module: header("Status: 404 Not Found"); I am running apache 2.2 with PHP using mod_fcgi on a Windows 7 machine and sending the header using just header("HTTP/1.0 404 Not Found"); seems to work fine. Is this something that

What is the most appropriate HTTP status code to return if a required header is missing?

我只是一个虾纸丫 提交于 2019-12-30 05:32:16
问题 I read What HTTP status response code should I use if the request is missing a required parameter? but it did not specifically ask about headers and there didn't seem to be a consensus. The context of this question assumes successful authentication. I'm currently favoring either a 400 (though that doesn't feel right because this isn't really a case of "malformed syntax") or 403. Given 403's description: The server understood the request, but is refusing to fulfill it. Authorization will not

Is it OK to return a HTTP 401 for a non existent resource instead of 404 to prevent information disclosure?

戏子无情 提交于 2019-12-28 12:12:13
问题 Inspired by a thought while looking at the question "Correct HTTP status code when resource is available but not accessible because of permissions", I will use the same scenario to illustrate my hypothetical question. Imagine I am building a a carpooling web service. Suppose the following GET /api/persons/angela/location retrieves the current position of user "angela". Only angela herself and a possible driver that is going to pick her should be able to know her location, so if the request is

Resolve HTTP 304 - not modified in AJAX call made via GWT

前提是你 提交于 2019-12-25 16:39:44
问题 We are using an application made in GWT with the server as tomcat. The project runs fine normally, however there are situations where the server is restarted. At such point of time, the ajax call made by the code below returns blank text with the status code as 304 RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.POST, URL.encode(serverUrl)); //-- serverUrl is the url to which this call is posted to. requestBuilder.setHeader("Content-Type", "application/x-www-form-urlencoded"

QNetworkAccessManager doesn't handle HTTP Status Code 308

不打扰是莪最后的温柔 提交于 2019-12-25 10:08:20
问题 I'm testing my code for compatibility with HTTP 3xx status codes (redirects). I'm interested in codes 301, 302, 303, 307 and 308. All of those work fine with my code, except 308. My client testcase is Qt/C++ based, and my testing server is python-based. I'll post the code of both. client.cpp : #include <QGuiApplication> #include <QObject> #include <QByteArray> #include <QNetworkAccessManager> #include <QNetworkRequest> #include <QNetworkReply> int main(int argc, char *argv[]) {

Extending a basic web crawler to filter status codes and HTML

落花浮王杯 提交于 2019-12-25 05:23:11
问题 I followed a tutorial on writing a basic web crawler in Java and have got something with basic functionality. At the moment it just retrieves the HTML from the site and prints it to the console. I was hoping to extend it so it can filter out specifics like the HTML page title and the HTTP status code? I found this library: http://htmlparser.sourceforge.net/ ... which I think might be able to do the job for me but could I do it without using an external library? Here's what I have so far: