Redirecting with a 201 created

I think you’re confusing two different semantic responses – one is telling the client that you successfully created a resource, and where it is. Whether the client goes to fetch it or not is a different story. The second is telling the client that it has sent the wrong location URI for a resource it’s … Read more

Get Http Status Code with OkHttp

You can use HttpResponse class and using that you can access the status code as follows; HttpResponse httpResponse = client.newCall(request).execute(); httpResponse.getStatusLine().getStatusCode(); If you are using com.squareup.okhttp.Response then you can use the code() method to get the HTTP status code. Response httpResponse = client.newCall(request).execute(); httpResponse.code();

HTTP Status 202 – how to provide information about async request completion?

Definitely do not abuse existing HTTP headers for this. Since it’s your own server, you get to define what the response looks like. You can (and should) pick whatever response works best for the intended recipient of this information and return the actual information in the response body. For example, if you are only interested … Read more

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

As i’m reading it, 415 Unsupported Media Type sounds like the most appropriate. From RFC 2616: 10.4.16 415 Unsupported Media Type The server is refusing to service the request because the entity of the request is in a format not supported by the requested resource for the requested method. Yeah, the text part says “media … Read more

401 Unauthorized vs 403 Forbidden: Which is the right status code for when the user has not logged in? [duplicate]

The exact satisfying one-time-for-all answer I found is: Short answer: 401 Unauthorized Description: While we know first is authentication (has the user logged-in or not?) and then we will go into authorization (does he have the needed privilege or not?), but here’s the key that makes us mistake: But isn’t “401 Unauthorized” about authorization, not … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)