http-status-codes

Laravel, how to redirect as 301 and 302

∥☆過路亽.° 提交于 2019-12-02 20:06:35
I cannot find info for redirecting as 301/302 in the Laravel docs . In my routes.php file I use: Route::get('foo', function(){ return Redirect::to('/bar'); }); Is this a 301 or 302 by default? Is there a way to set it manually? Any idea why this would be omitted from the docs? Whenever you are unsure, you can have a look at Laravel's API documentation with the source code. The Redirector class defines a $status = 302 as default value. You can define the status code with the to() method: Route::get('foo', function(){ return Redirect::to('/bar', 301); }); I update the answer for Laravel 5! Now

Proper status codes for JSON responses to Ajax calls?

試著忘記壹切 提交于 2019-12-02 18:02:21
My project is returning JSON to Ajax calls from the browser. I'm wondering what the proper status code is for sending back with responses to invalid (but successfully handled) data submissions. For example, jQuery has the following two particular callbacks when making Ajax requests: success : Fired when a 200/2xx status code is delivered along with the response. error : Fired when 4xx, 5xx, etc, status codes come back with the response. If a user attempts to create a new "Person" object, I send back a JSON representation of the newly created object upon success, thus giving javascript access

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

被刻印的时光 ゝ 提交于 2019-12-02 14:37:30
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 server to client and modify the status code before it reaches the client? Any advice would be much

how to get http status value?

风流意气都作罢 提交于 2019-12-02 14:32:46
问题 first of all i asked something before and i got another question please take a look this one first I send some values to another url and about that i made a question and got an answer, and finally i have another question if like i said that above question, i send some values to other url using spring and httpclient like this, HttpClient client = HttpClientBuilder.create().build(); HttpPost post = new HttpPost("http://test.com"); post.setEntity(new UrlEncodedFormEntity(values arrayList));

Correct http status code for resource which requires authorization

痞子三分冷 提交于 2019-12-02 14:11:48
There seems to be a lot of confusion about the correct http status code to return if the user tries to access a page which requires the user to login. So basically what status code will be send when I show the login page? I'm pretty sure we need to use a status code in the 4xx range. I'm not talking about HTTP authentication here, so that's at least 1 status code we aren't going to use ( 401 Unauthorized ). Now what should we use? The answers (also here on SO) seem to vary: According to the answer here we should use 403 Forbidden . But in the description of the status code is: Authorization

Create request with POST, which response codes 200 or 201 and content

怎甘沉沦 提交于 2019-12-02 13:52:06
Suppose I write a REST service whose intent is to add a new data item to a system. I plan to POST to http://myhost/serviceX/someResources Suppose that works, what response code should I use? And what content might I return. I'm looking at the definitions of HTTP response codes and see these possibilities: 200: Return an entity describing or containing the result of the action; 201: which means CREATED. Meaning *The request has been fulfilled and resulted in a new resource being created. The newly created resource can be referenced by the URI(s) returned in the entity of the response, with the

python http status code

心已入冬 提交于 2019-12-02 13:16:46
问题 I'm writing my own directory buster in python, and I'm testing it against a web server of mine in a safe and secure environment. This script basically tries to retrieve common directories from a given website and, looking at the HTTP status code of the response, it is able to determine if a page is accessible or not. As a start, the script reads a file containing all the interesting directories to be looked up, and then requests are made, in the following way: for dir in fileinput.input(

Does java.net.HttpUrlConnection always throw IOException if there is an error status return by Server?

假如想象 提交于 2019-12-02 09:55:32
I am using java.net.HttpUrlConnection to make Http request to my Server. I realized that if the Server return an error status (400 for example). HttpUrlConnection will throw an IOException corresponding to the error status. My question is: Does HttpUrlConnection always throw an IOException if the server return an error status (4xx, 5xx)? I take a look at HttpUrlConnection API description but I couldn't answer my question. Updated: Please see my test: public static void main(String[] args) { try { String url = "https://www.googleapis.com/oauth2/v3/userinfo?access_token=___fake_token";

Auth failing - 999- HTTP status code is not handled or not allowed

大兔子大兔子 提交于 2019-12-02 09:08:39
I using scrapy , and I would like to get Ignoring response URL.I just see in the output console this: DEBUG: Ignoring response <999 https://www.mywebsite.com >: HTTP status code is not handled or not allowed. According to the documentation here you can add a list of HTTP status codes which should be handled by your spider even if they are not allowed by default. In your case you have to add following line to your spider definition: handle_httpstatus_list = [999] This will cause the spider to get the result even with this status code. Next time before asking a question pleas look through

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

ε祈祈猫儿з 提交于 2019-12-02 04:00:29
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 because I can prevent this error from occurring in the server if I return a nice error message back to