http-status-codes

MS Edge handles 401 errors thus bypassing my error handler

十年热恋 提交于 2019-12-24 08:41:33
问题 I have code to make ajax calls to my web service in javascript as follows: $.ajax( { url: url, data: json, type: "POST", processData: false, contentType: "application/json", timeout: 10000, dataType: "text", global: false, success: function (result, jqXHR) { sccParams = { result: result, jqXHR: jqXHR, } successResult(sccParams) }, error: function (jqXHR, textStatus, errorThrown) { errParams = { jqXHR: jqXHR, textStatus: textStatus, errorThrown: errorThrown, } errorHandler(errParams); } });

Custom HTTP reason phrase using ExceptionMapper

北战南征 提交于 2019-12-24 06:46:02
问题 I have defined the following Exception Mapper to handle the custom HttpCustomException package com.myapp.apis; import com.myapp.apis.model.HttpCustomException; import com.myapp.apis.model.HttpCustomExceptionStatusType; import com.myapp.apis.model.HttpCustomNotAuthorizedException; import javax.ws.rs.core.Response; import javax.ws.rs.ext.ExceptionMapper; import javax.ws.rs.ext.Provider; @Provider public class HttpCustomExceptionMapper implements ExceptionMapper <HttpCustomException> { @Override

How can I detect if a URL is redirected to another one?

这一生的挚爱 提交于 2019-12-24 03:19:33
问题 I use this code to make a 'GET' request to urls. var request = WebRequest.Create(uri) as HttpWebRequest; request.Method = "GET"; var response = request.GetResponse() as HttpWebResponse; var status = response.StatusCode; // returns HttpStatusCode.OK So, the probelem is when a url is redirected to another one, I can't detect it. For example; url is: http://site.com that redirects to http://www.site.com but when I make a request to http://site.com it returns a HttpStatusCode.OK for it -instead

In Rails 3.2.3 server I get error 304 Not Modified (5ms)

点点圈 提交于 2019-12-24 02:06:05
问题 I am newbie to ruby and rails for several months now.I took a class for ruby and rails which allowed me to create a restaurant blog site. Well I recently started revamping the site to make for my friend. So it's merely just changing some things around pictures, wording, etc. When I created the other blog completely I made a register to log in page which they need to create a log in in order to create and post a comment etc. Everything seems to work fine when I run rails s for the local host

HTTP status while POST with incorrect data (using id of resource which does not exist)

£可爱£侵袭症+ 提交于 2019-12-24 01:07:05
问题 What would be the correct HTTP status to return when I am performing the POST request to create a new user, but one of its parameters is incorrect - the company id I am including with the user data doesn't exist in the database. POST data: {username: 'newuser', age: 99, company_id: 34 } the company with id 34 does not exist in the database. I was thinking whether that could be: 400, kind of invalid data, but it is valid but nonexistent id 404 - but it is not so clear which resource does not

HTTP status while POST with incorrect data (using id of resource which does not exist)

╄→尐↘猪︶ㄣ 提交于 2019-12-24 01:03:05
问题 What would be the correct HTTP status to return when I am performing the POST request to create a new user, but one of its parameters is incorrect - the company id I am including with the user data doesn't exist in the database. POST data: {username: 'newuser', age: 99, company_id: 34 } the company with id 34 does not exist in the database. I was thinking whether that could be: 400, kind of invalid data, but it is valid but nonexistent id 404 - but it is not so clear which resource does not

Format for 406 Not Acceptable payload?

为君一笑 提交于 2019-12-24 00:53:50
问题 In a 406 Not Acceptable response: The server SHOULD generate a payload containing a list of available representation characteristics and corresponding resource identifiers from which the user or user agent can choose the one most appropriate. A user agent MAY automatically select the most appropriate choice from that list. However, this specification does not define any standard for such automatic selection, as described in RFC7231 Section 6.4.1. Is there a preferred format for that " list of

Get Http Status Code from an ajax response with jquery

安稳与你 提交于 2019-12-23 14:42:09
问题 In my current spring project, when I submit a form to server, the response is handled by this method: $('form.form').each(function () { var form = this; $(form).ajaxForm(function (data) { form.reset(); $(".alert-info").find("#alert").html(data); $(".alert-info").show(); }); }); In my controller, the submission is handled by a method like this: @RequestMapping(value="cadastra", method=RequestMethod.POST) @ResponseBody @ResponseStatus(HttpStatus.CREATED) public void cadastra(@ModelAttribute(

Is there a maximum HTTP status code message length?

萝らか妹 提交于 2019-12-23 12:29:29
问题 I'm working on a project where I'm building the frontend and someone else is building an API. I was proposing the following structure for all requests, sent as JSON: { "success": true, // true/false "message": null, // a string if success==false indicating the error "data": {} // The actual data in the response } They are more interested in making the API more RESTful, and instead of a "message" field they are proposing sending a message back in the status code message, in the HTTP headers,

How to change http status codes in Strongloop Loopback

◇◆丶佛笑我妖孽 提交于 2019-12-23 10:59:28
问题 I am trying to modify the http status code of create. POST /api/users { "lastname": "wqe", "firstname": "qwe", } Returns 200 instead of 201 I can do something like that for errors: var err = new Error(); err.statusCode = 406; return callback(err, info); But I can't find how to change status code for create. I found the create method: MySQL.prototype.create = function (model, data, callback) { var fields = this.toFields(model, data); var sql = 'INSERT INTO ' + this.tableEscaped(model); if