Questions tagged [http-response]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
64
votes
9answers
109k views

When to use HTTP status code 404 in an API

I am working on a project and after arguing with people at work for about more than a hour. I decided to know what people on stack-exchange might say. We're writing an API for a system, there is a ...
56
votes
6answers
47k views

Should “No Results” be an error in a RESTful response?

I'll describe an example: I start making an API for a baking shop. The API will allow people to search their catalogus for baking products, such as home-made minty chocolate chip cookies using api....
40
votes
11answers
54k views

Should a REST API return a 500 Internal Server Error to indicate that a query references an object that does not exist?

I am working with a REST API which resides on a server that handles data for a multitude of IoT devices. My task is to query the server using the API to collect specific performance information about ...
40
votes
4answers
9k views

Any technical reason not to use my own HTTP response code TEXT if I develop both server & Client?

Over the years, I have seen quite a few questions on this site along the lines of "can I invent my own HTTP response codes"? Generally asked by those who are developing both the server and client. The ...
24
votes
2answers
9k views

Levels of user permissions in a RESTful API

Let's say I have a company that ranks the cutest cats on the internet. I offer a resource at /cats/ which provides users with the latest, cutest adorable cats. Users can either get just the top 3 cats ...
11
votes
2answers
7k views

What are some best practices for cookie based web authentication?

I'm working on a small side project using CGI and Python (scalability is not an issue and it needs to be a VERY simple system.) I was thinking of implementing authentication using cookies, and was ...
9
votes
1answer
2k views

Use 404 or 200 when null result (REST) [duplicate]

Let's assume we have an Entity { "id": 1 "inProgress": true, } We have endpoints: /api/v1/entities/ for fetching all entities, /api/v1/entities/1 for fetching entity with id = 1 /api/v1/...
7
votes
1answer
5k views

RESTful HTTP OPTIONS request content

I'm having trouble determining what I might put in the body of a response to an OPTIONS request? are there conventions? standards? What do you put? do you just provide a list of other METHODS? should ...
6
votes
2answers
142 views

Is repeating an identifier on an API request and response considered a code smell

Is it weird to have an identifier such as (_id) on a request which you send to the API, which "enriches" the request and sends back a response with the same identifier (but obviously more enriched ...
6
votes
1answer
10k views

Rendering head :ok vs head :no_content. Any good practices?

Whenever I take in data and do something like delete a post, etc. I generally return head :no_content. For example: def destroy @post = Post.find_by(external_id: params[:post_id]) @post.destroy! ...
5
votes
3answers
2k views

Is Model a better place to set HTTP status code?

In MVC usually the controller sets whatever needs to be sent back to the client/View, including HTTP status code, e.g.: class Controller { public function get(Request req, Response resp) { ...
5
votes
4answers
1k views

What are the benefits of using meta tag/JavaScript redirection over HTTP header redirection?

Upon inspecting Twitter's URL shortening service http://t.co, I noticed that, instead of redirecting to the goal URL using a Location HTTP header and a 3xx HTTP status code, it redirects using the ...
4
votes
4answers
275 views

Should I write an integration test that verifies rate limits?

This test would call a web service over and over for about a minute to confirm that a particular response code is returned, notifying us of our rate limit being reached. Not only is it a very slow ...
4
votes
3answers
3k views

Web Service and Message Queue

We're looking at creating a web services/REST API layer that will be consumed by web and mobile clients. To make the solution more robust I was considering putting the commands from PUT, POST, and ...
4
votes
2answers
317 views

HTTP response header to indicate request was forwarded to another server by reverse proxy

Given a system of services and a reverse proxy, such that requests may either be conclusively processed by the proxy or ultimately handled by any of the services behind the proxy. Consideration has ...
4
votes
1answer
147 views

Whatever happened to HTTP SEARCH? [closed]

It seems 5 years ago there was a proposal for a HTTP SEARCH request, but it does not appear to have been adopted and it not widely supported. Are there any factual documents or citations which shed ...
4
votes
1answer
2k views

The Request/Response Cycle

When User A decides he want to pay a visit to http://example.com/ it all begins with a Request. A short moment later he is given a Response. In this cycle Request-Response a lot is going on, in ...
3
votes
4answers
807 views

Proper RESTful web service response code usage

Assuming I create a RESTful web service that looks up a user in a database given the id as a parameter. If the user does not exist, should I return a 404 response (because user not found)? Or a 200 ...
3
votes
1answer
103 views

Meaningful response to the user after his uploaded CSV was processed?

A user uploads a CSV to the server to be inserted into the database and I would like to return a meaningful response to this user. My thoughts : { inserted : x records discarded : y records } ...
3
votes
2answers
214 views

Why HTTP Servers send information about themselves in HTTP Headers?

Most of the HTTP Servers I know send their application name and version in response http headers as default behaviour. (Nginx, IIS, Apache etc.) Of course we can change the default behaviour but I ...
3
votes
2answers
124 views

How should I specify locations where clients can resolve authorization problems in a REST API?

I'm working through an API design where a user's authentication will be verified by the presence of a valid forms authentication ticket in a session cookie. However, there are additional levels of ...
3
votes
0answers
1k views

pinging vs socket vs push notifications

I develop mobile apps, now im working on a very big project building a tool for the employees to be heavily used. Now the app is on development mode, and testing with few users, but will need to be ...
3
votes
0answers
111 views

Response Header for illegal file (format)

I have a simple upload-servlet and need to report if a file is illegal and has not been added. For some reason i am not allowed to give a html-body back, so i need to use the response-header. ...
2
votes
1answer
408 views

Not prohibited, but disallowed — which http error code should I return?

I know that if user is forbidden in an admin's area, I should return 401 or 403 status error code. However, what I want to prohibit an admin for accessing a user's dashboard also? An admin has its own ...
2
votes
2answers
249 views

HTTP status 500 for missing file

By default, the HTTP response code for "file not found" has always been 404. I never really thought about it until recently someone was saying that if the missing file is part of an application then ...
2
votes
1answer
74 views

How do I create an HTTP PUT request that modifies the resource in many ways

I have a NodeJs backend that interacts with MySQL database. Let us assume that I have a schema similar to this: Book id name Author id book_id name So, I have two tables named Book and ...
2
votes
2answers
2k views

Designing a REST API: setting business logic error codes in http headers or within the response payload

I am designing a REST api backend that is meant to be consumed by a javascript front-end. I am not sure how to communicate server-side business logic errors (e.g. a user trying to retrieve his ...
2
votes
2answers
1k views

Do web applications use HTTP as a transport layer, or do they count as an integral part of the HTTP server?

Given an HTTP server (e.g. Apache, IIS) and a web application (user code running in the server using PHP, ASP.NET and the likes), which of those can decide which HTTP status code to return for any ...
2
votes
1answer
11k views

REST and redirecting the response

I'm developing a RESTful service. Here is a map of the current feature set: POST /api/document/file.jpg (creates the resource) GET /api/document/file.jpg (retrieves the resource) DELETE /api/...
2
votes
0answers
1k views

How to persist a session cookie in a PSR7 request/response middleware?

I am building a package that implements native-like sessions in a PSR7 middleware architecture. I created a middleware which is responsible to create and persist a session cookie. The session is also ...
2
votes
1answer
754 views

Is Google's Page Speed not working fine?

I've been making small improvements to a public ASP.NET site that I have and have ran it through Google's online Page Speed several times. I have a specific problem, but something that really threw me ...
1
vote
3answers
488 views

Which HTTP status codes are really OK?

I am writing an application to report to the user(devs) when their website fails. And what I mean by fails which is unfunctional or needs to report the problem to devs. I do understand that status ...
1
vote
3answers
6k views

Is path in Set-Cookie URL encoded?

I'm writing some code that sets cookies and I'm wondering about the exact semantics of the Set-Cookie header. Imagine the following HTTP header line: Set-Cookie: name=value; Path=/%20 For with path ...
1
vote
1answer
3k views

How to respond with error message when making AJAX calls

I have an app that wasn't written by myself. If there is an error such as an invalid ID given as a parameter, I would return something like: (200 code) { "success": 0, "error": "The row ...
1
vote
1answer
147 views

Which HTTP code has higher priority: 403 or 415?

Let's consider the following scenario. I need to access a resource hosted on server X. I want to get this resource in a Y format, so along with my request I send the Accept: Y header. Unfortunately X ...
1
vote
2answers
2k views

How to Distinguish When a 404 Status is Real in RESTFul Service

We have ServiceA with these endpoints defined: /devices: get: queryParameters: make: type: string repeat: false required: false model: type: string ...
1
vote
2answers
819 views

Microservices, browsers and HTTP requests

In the old days we used to create a single .gif file for the entire application to avoid too many trips from the browser to the server. Similarly, we used to combine different types of information in ...
1
vote
1answer
713 views

How to handle API responds with DTO or Error Message

I have a mobile app and an API. The mobile app is set up to expect back a DTO from the API but has no information if an request was unsuccessful. This needs to be updated so that better messaging is ...
1
vote
3answers
503 views

Store generated image in database or generate it on server/client

I have been thinking what could be the fastest way to show base64/img data to the user, i could generate the data when the user is registered and then store it to database, or generate it every time ...
1
vote
1answer
134 views

An application to get statistical data about HTTP Request/Response

I'm looking for an application which takes the address of a website, browses that website, and provides reports based on some user-defined criteria about the HTTP requests/responses. For example, this ...
1
vote
0answers
181 views

How to simplify design and remove duplication in java layered architecture?

I've the following project structure (simplified): domain dto view In domain model is kept. dto classes are used to pass data from domain to view. And in view I've a controller and a handful of *req,...
0
votes
2answers
2k views

How can I reduce http request while I have hundreds of images and thousands of users [closed]

I need an idea or concept how to reduce http request. Conditions: 1000s of users(android/iphone) active 100s of small images (150kb/image) to be fetched Simply by giving each image a hardcoded link, ...
0
votes
2answers
591 views

Is it acceptable to escalate a software error to HTTP 500?

Should an error 500 only be thrown by the web server, or is it acceptable for your program to throw one itself? try { some bad code; } catch (Exception) { set_header_code(500); set_content_type('...
0
votes
1answer
87 views

Most approriate HTTP return code when record locked for update due to invalid data

Context Typical restful CRUD service, including PATCH method, whose API validates fields (eg the "name" field may not contain digits). However, data in the database (from backdoor ETL load) ...
0
votes
1answer
656 views

REST API implementation for graph data - Where to calculate graph units

We have a graph that shows bandwidth usage over time. The bandwidth is returned from the server in bytes. We need to decide which units to show in the graph in case there are several different ...
0
votes
1answer
480 views

Appropriate HTTP status code when authorization server is unavailable

We have authorization server which is in charge of checking token validity, expiration etc. Which HTTP status code should be returned if the authorization server is down? Should it be 401 with "...
0
votes
2answers
226 views

Status code for middleware? 200 or 4XX , 5XX?

I have a design dilemma in deciding the response status code and architecture for a middleware we are designing. So the Client Calls MiddleWare, And middleware calls the 3rd party service to get car-...
0
votes
2answers
809 views

Including aggregate data in web service response in DDD

I've been struggling with this issue for a while. Let's say you have a business application that has a rich domain and in one of the front-end views you show a list of open Orders. In this view you ...
-1
votes
2answers
139 views

What does a proper server response look like? [closed]

tl;dr Which is the best server response for an endpoint to get a user's age? 30 or {"age":30} or {"metadata":{"time":1561919615,"status":200},"age":30} or something else? I am writing a server using ...
-1
votes
2answers
102 views

Http status and reponse in case the API gives out partial response

I have an API whose job is to aggregate resources obtained by calling multiple other APIs and then give out the aggregated response to the client. Currently even if one or more dependent API calls ...