http-status-codes

406 Not Acceptable error GET parameter issue?

倖福魔咒の 提交于 2019-11-28 06:39:59
问题 Can anyone please tell me why the following URL returns a 406 error: http://kolek.to/functions/remote-upload.php?url=http%3A%2F%2Fben-major.co.uk%2Fhosting%2Fbm-equipment%2Faxe-2.jpg&item_id=2 Removing the ?url= parameter seems to make everything fine: http://kolek.to/functions/remote-upload.php?item_id=2 For your reference, the content of remote-upload.php is as follows: <?php require_once('../models/api.php'); $request_url = urldecode($_REQUEST['url']); $item_id = $_REQUEST['item_id']; echo

How to specify HTTP error code?

人盡茶涼 提交于 2019-11-28 04:26:18
I have tried: app.get('/', function(req, res, next) { var e = new Error('error message'); e.status = 400; next(e); }); and: app.get('/', function(req, res, next) { res.statusCode = 400; var e = new Error('error message'); next(e); }); but always an error code of 500 is announced. Per the Express (Version 4+) docs, you can use: res.status(400); res.send('None shall pass'); http://expressjs.com/4x/api.html#res.status <=3.8 res.statusCode = 401; res.send('None shall pass'); A simple one liner; res.status(404).send("Oh uh, something went wrong"); You can use res.send('OMG :(', 404); just res.send

Is it correct to return 404 when a REST resource is not found?

假如想象 提交于 2019-11-28 04:22:01
Let's say I have a simple Jersey REST resource as follows: @Path("/foos") public class MyRestlet extends BaseRestlet { @GET @Path("/{fooId}") @Produces(MediaType.APPLICATION_XML) public Response getFoo(@PathParam("fooId") final String fooId) throws IOException, ParseException { final Foo foo = fooService.getFoo(fooId); if (foo != null) { return Response.status(Response.Status.OK).entity(foo).build(); } else { return Response.status(Response.Status.NOT_FOUND).build(); } } } Based on the code above, is it correct to return a NOT_FOUND status ( 404 ), or should I be returning 204 , or some other

How can I get the IIS substatus code from an Exception?

梦想的初衷 提交于 2019-11-28 03:58:02
问题 I'm handling exceptions with an HttpModule in a manner such as this: int errorCode = 500; HttpApplication httpApp = (HttpApplication)sender; try { if (httpApp.Server != null) { Exception ex; for (ex = httpApp.Server.GetLastError(); ex != null; ex = ex.InnerException) { try { HttpException httpEx = ex as HttpException; if (httpEx != null) errorCode = httpEx.GetHttpCode(); // ... retrieve appropriate content based on errorCode } catch { } } } For HTTP status codes (ex: 302, 404, 503, etc)

Is returning HTTP 409 appropriate for a validation check?

偶尔善良 提交于 2019-11-28 02:56:32
问题 I have a service where some validation rules must be checked before a particular operation should be able to take place. For instance, the client should not generate printable reports if all of the validation rules are not being met. However, an individual client may not have all of the required information (that user may only be able to access a subset of the data that is used to determine validation success), so a request must be sent to the server: basically "is a thing valid between start

Appropriate HTTP status code for request specifying invalid Content-Encoding header?

戏子无情 提交于 2019-11-28 02:25:34
问题 What status code should be returned if a client sends an HTTP request and specifies a Content-Encoding header which cannot be decoded by the server? Example A client POSTs JSON data to a REST resource and encodes the entity body using the gzip coding. However, the server can only decode DEFLATE codings because it failed the gzip class in server school. What HTTP response code should be returned? I would say 415 Unsupported Media Type but it's not the entity's Content-Type that is the problem

How to get HTTP status code of <img> tags

馋奶兔 提交于 2019-11-28 01:52:45
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? No, there is no way to get the HTTP status from a request made by an img tag in JavaScript. You could write a firefox plugin, chrome/safari extension to do that. An alternative would be using AJAX to

Android Https Status code -1

会有一股神秘感。 提交于 2019-11-28 01:39:26
问题 I'm connecting to a web server from my android application via HttpsUrlConnection or HttpUrlConnection depending on settings. For now I didn't have any kind of problem, but yesterday I start getting http/https status response -1 . There is no way the web server return me this even if there is some kind of error. The server which I'm connection to is designed to return errorCode and errorString when there is some kind of problem. Here is the code I'm using,but I don't think the problem is here

Setting HTTP Status in ASP.NET MVC controller results does not render view

与世无争的帅哥 提交于 2019-11-28 00:49:52
问题 I have a custom ActionResult for returning certain HTTP Errors, like NotFoundResult and ForbiddenResult, they all derive from ViewResult. I use them for instances like short circuiting actions with a 404 if an entity was not found in the database during the course of an action. Within these result objects, I set the HTTP Status to the appropriate number. When I do that, the view that these ViewResults reference does not render. I have to leave the status as 200 OK in order for my view to be

Which HTTP status code to say username or password were incorrect?

六月ゝ 毕业季﹏ 提交于 2019-11-27 23:21:35
问题 I am implementing a simple registation/login module. While testing user credentials, I start thinking which HTTP status code will be appropriate, for the situation if a user send a request with incorrect credentials. At first, I thought 401 Unauthorized would be a nice status code, but it seems it will be better to use it when a user is trying to get some resource without authorisation. After, I switched to 409 Conflict This code is only allowed in situations where it is expected that the