Closed Bug 414165 Opened 18 years ago Closed 5 years ago

Firefox with a "201 created" response should perform a redirect to the Location field

Categories

(Core :: Networking: HTTP, defect, P3)

x86
Linux
defect

Tracking

()

RESOLVED INVALID

People

(Reporter: andy, Unassigned)

Details

(Whiteboard: [necko-backlog])

User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11 Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11 As I understand the 201 "Created" status code means that the browser should redirect to the url provided in the Location header From http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.2 "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" I assume that the spec means that the newly create resource WILL be referenced (ie displayed) or is that not the case? Andy Bailey http://www.hazlorealidad.com Reproducible: Always Steps to Reproduce: 1.do a post to a url, the server responds 201 created with a Location header 2.The browser doesnt redirect and shows a blank page (consistent with the zero length content) Actual Results: POST /qualit/processInstance/ HTTP/1.1 Host: localhost:10000 User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11 Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 Accept-Language: en-us,en;q=0.7,es-co;q=0.3 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Referer: http://localhost:10000/qualit/processDefinition/ Content-Type: application/x-www-form-urlencoded Content-Length: 23 processName=hello+world HTTP/1.x 201 Created Content-Length: 0 Location: http://localhost:10000/qualit/processInstance/2005.xml The browser shows http://localhost:10000/qualit/processInstance/ in the address bar and a blank screen Expected Results: I expect it to do the redirect. If the response code is changed to 303 it works as I expect.
Component: General → Networking: HTTP
Product: Firefox → Core
QA Contact: general → networking.http
Reporter, can you please post your testcase?
Im using Jersey the JSR311 RI I made a short test case that uses a GET instead of a POST (as in the original) import java.net.URI; import java.net.URISyntaxException; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.core.Response; @Path("/test") public class TestCase { @GET @Path("create") public Response create() { URI uri=null; try { uri = new URI("http://www.google.com"); } catch (URISyntaxException e) { e.printStackTrace(); } return Response.created(uri).build(); } public static void main(String[] args) throws IOException { String url = "http://localhost:11000/"; HttpServer s = HttpServerFactory.create(url); System.out.println("Server Running at " + url); s.start(); } } I type into the browser address bar http://localhost:11000/test/create Live http headers shows: http://localhost:11000/test/create GET /test/create HTTP/1.1 Host: localhost:11000 User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11 Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 Accept-Language: en-us,en;q=0.7,es-co;q=0.3 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive HTTP/1.x 201 Created Content-Length: 0 Location: http://www.google.com And firefox shows a blank page
Whiteboard: [necko-backlog]
Priority: -- → P1
Priority: P1 → P3

I can confirm this is still an issue. I'm on 83.0, macOS (Intel-based) Big Sur. My test setup was slightly different but effectively the same:

let express = require('express');
const app = express()

app.get('/', (req, res) => {
    res.status(201);
    res.set('Location', '/redirected');

    console.log('Set headers.');
    res.end();
});

app.get('/redirected', (req, res) => {
    res.status(200);
    res.set('Content-Type', 'text/plain');
    res.send('Hello, World!');

    console.log('Redirected!');
    res.end();
});

app.listen(5000, () => {
    console.log("Started listening.");
});

I wonder if a redirect should be done at all. From https://httpstatuses.com/201, "The request has been fulfilled and has resulted in one or more new resources being created.", and "The 201 response payload typically describes and links to the resource(s) created." This response code therefore seems to indicate that the request has been fulfilled by the creation of a resource. It is the payload's duty to indicate this to the user.

I'm new to the code base, but from my understanding, this function handles response status codes that are redirects (i.e., 3xx status codes).

@jstutte Perhaps we should close this issue?

Flags: needinfo?(jstutte)

Thanks for the analysis! I'd agree.

Status: UNCONFIRMED → RESOLVED
Closed: 5 years ago
Flags: needinfo?(jstutte)
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.