Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
redirect with status code 307 (for POST)
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  11 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Colin  
View profile  
 More options Nov 2, 7:04 pm
From: Colin <colin...@gmail.com>
Date: Mon, 2 Nov 2009 16:04:59 -0800 (PST)
Local: Mon, Nov 2 2009 7:04 pm
Subject: redirect with status code 307 (for POST)
Hello,

I'm working on some REST style webservices and trying to use the
UrlRewrite tool to help map some old urls to the new ones.  It seems
like the perfect tool for this.

What I need to do is return a redirect status code when the client
POSTs data to certain URLs.  I want the client to re-POST the data to
the new URL, and my understanding from wikipedia is that HTTP status
307 instructs the client to resubmit its request to the new Location
using the same method (eg, do POST again, do not change to GET.)

I can't get UrlRewrite ver 2.6 to return 307.  I've tried "permanent-
redirect", "redirect", and "temporary-redirect" but they return
statuses 301, 302, and 302, respectively.  When wget receives these
statuses in response to a POST it always uses GET for the new Location
(not what I want.)

I have two questions:
1.  Does result 307 actually instruct clients to retry their request
using the same method?
2.  Is there a way to get UrlRewrite to return status 307?

Also, this redirect is cross-context so I cannot try "forward".

thanks,
Colin


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Wim De Smet  
View profile  
 More options Nov 4, 4:03 am
From: Wim De Smet <krom...@gmail.com>
Date: Wed, 4 Nov 2009 10:03:46 +0100
Local: Wed, Nov 4 2009 4:03 am
Subject: Re: redirect with status code 307 (for POST)
Hi,

On Tue, Nov 3, 2009 at 1:04 AM, Colin <colin...@gmail.com> wrote:
> I can't get UrlRewrite ver 2.6 to return 307.  I've tried "permanent-
> redirect", "redirect", and "temporary-redirect" but they return
> statuses 301, 302, and 302, respectively.  When wget receives these
> statuses in response to a POST it always uses GET for the new Location
> (not what I want.)

I think "redirect" could work, but I'm not sure. Are you sure you're
using a version of the servlet API that supports 307?

Version 3.2 is plenty stable btw, I'd recommend upgrading.

> I have two questions:
> 1.  Does result 307 actually instruct clients to retry their request
> using the same method?

It should. But keep in mind that POST after POST has always been a bit
buggy and is only supposed to work on HTTP/1.1 clients. How about
proxying the request? I think that might work.

> 2.  Is there a way to get UrlRewrite to return status 307?

Have a look at the <run> method, it allows you to get at the
HttpServletResponse so you can set the status yourself. Not very
elegant, but I'm pretty sure it'll work.

regards,
Wim


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Avlesh Singh  
View profile  
 More options Nov 4, 11:24 pm
From: Avlesh Singh <avl...@gmail.com>
Date: Thu, 5 Nov 2009 09:54:21 +0530
Local: Wed, Nov 4 2009 11:24 pm
Subject: Re: redirect with status code 307 (for POST)

> > I have two questions:
> > 1.  Does result 307 actually instruct clients to retry their request
> > using the same method?

> It should. But keep in mind that POST after POST has always been a bit
> buggy and is only supposed to work on HTTP/1.1 clients. How about
> proxying the request? I think that might work.

There is a SLIGHT misunderstanding here. Status code 307 is NOT expected to
work as described in the thread. Underneath is a short snippet from W3 RFC
on status codes. This is what it says on the 3XX series -

This class of status code (3XX) indicates that further action needs to be

> taken by the user agent in order to fulfill the request. The action required
> MAY be carried out by the user agent without interaction with the user *if
> and only if the method used in the second request is GET or HEAD*. A
> client SHOULD detect infinite redirection loops, since such loops generate
> network traffic for each redirection.

For more read here - http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

Bottomline, the redirect request can ONLY be GET or HEAD. This is the harsh
realty of life!

2.  Is there a way to get UrlRewrite to return status 307?


Nope. Not right now. But based on the description, I don't think you need
it.

More questions?

Cheers
Avlesh

On Wed, Nov 4, 2009 at 2:33 PM, Wim De Smet <krom...@gmail.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Wim De Smet  
View profile  
 More options Nov 5, 5:49 am
From: Wim De Smet <krom...@gmail.com>
Date: Thu, 5 Nov 2009 11:49:29 +0100
Local: Thurs, Nov 5 2009 5:49 am
Subject: Re: redirect with status code 307 (for POST)
Hi,

Actually I think you're missing an important modifier here: "without
interaction with the user". What the standard says is that redirect
works for any type, but in the case of a 307 POST the user client is
not allowed to redirect without asking for user confirmation. POST
after POST does indeed work AFAIK. It just doesn't work very well or
very consistently. If I'm not mistaken IE6 doesn't ask for
confirmation, but most other browsers will. I haven't tested it in a
while.

regards,
Wim


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Avlesh Singh  
View profile  
 More options Nov 5, 6:10 am
From: Avlesh Singh <avl...@gmail.com>
Date: Thu, 5 Nov 2009 16:40:49 +0530
Local: Thurs, Nov 5 2009 6:10 am
Subject: Re: redirect with status code 307 (for POST)

> Actually I think you're missing an important modifier here: "without
> interaction with the user". What the standard says is that redirect
> works for any type, but in the case of a 307 POST the user client is
> not allowed to redirect without asking for user confirmation. POST
> after POST does indeed work AFAIK. It just doesn't work very well or
> very consistently. If I'm not mistaken IE6 doesn't ask for
> confirmation, but most other browsers will. I haven't tested it in a
> while.

You misread it Wim. I'll try to be visual and explain it -

Request-1 (GET/POST/HEAD) -> Location: URL-2; Code: 307 -> Request-2 (ONLY
GET/HEAD)
If Request-1 is POST, then a redirect would also ask for a user confirmation
(this is how 307 differs from 302/303, wherein the requested resource is
treated as MOVED and the client is NOT asked to confirm)

Moreover, the 3xx response is supposed to be headers only with no body.
State-2 in the visual above CANNOT have a body. In this case you anyways
have no way of passing the post data back to the client. And even if you do,
they are NOT supposed to be used. As I earlier said redirects can only be
GET/HEAD.

Clear?

Cheers
Avlesh

On Thu, Nov 5, 2009 at 4:19 PM, Wim De Smet <krom...@gmail.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Wim De Smet  
View profile  
 More options Nov 5, 7:32 am
From: Wim De Smet <krom...@gmail.com>
Date: Thu, 5 Nov 2009 13:32:47 +0100
Local: Thurs, Nov 5 2009 7:32 am
Subject: Re: redirect with status code 307 (for POST)

I reiterate, I do not think I am misreading it. The RFC specifically
allows for a 307 to result in a POST request, namely here:
 "If the 307 status code is received in response to a request other
than GET or HEAD, the user agent MUST NOT automatically redirect the
request unless it can be confirmed by the user, since this might
change the conditions under which the request was issued. "

In principle, even a 301 should be able to redirect to a POST in the
second request. The real-world behaviour is for browsers to convert
the request into a GET though (see the note). A 303 was specifically
introduced to allow the server to indicate the request should be
converted to a GET. A 307 on the other hand, does not allow a client
to change the request method.

> Moreover, the 3xx response is supposed to be headers only with no body.
> State-2 in the visual above CANNOT have a body. In this case you anyways
> have no way of passing the post data back to the client. And even if you do,
> they are NOT supposed to be used. As I earlier said redirects can only be
> GET/HEAD.

The client is supposed to re-present the same post parameters to the
new location. I never said the server returned those parameters in
some way.

> Clear?

I really don't see how I'm misreading it. I think you simply have it
wrong in this case.

regards,
Wim


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Colin  
View profile  
 More options Nov 5, 9:20 am
From: Colin <colin...@gmail.com>
Date: Thu, 5 Nov 2009 06:20:10 -0800 (PST)
Local: Thurs, Nov 5 2009 9:20 am
Subject: Re: redirect with status code 307 (for POST)

On Nov 4, 3:03 am, Wim De Smet <krom...@gmail.com> wrote:

> > I have two questions:
> > 1.  Does result 307 actually instruct clients to retry their request
> > using the same method?

> It should. But keep in mind that POST after POST has always been a bit
> buggy and is only supposed to work on HTTP/1.1 clients. How about
> proxying the request? I think that might work.

Can you explain what you mean by "proxying the request"?

thanks,
Colin


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Wim De Smet  
View profile  
 More options Nov 5, 9:21 am
From: Wim De Smet <krom...@gmail.com>
Date: Thu, 5 Nov 2009 15:21:56 +0100
Local: Thurs, Nov 5 2009 9:21 am
Subject: Re: redirect with status code 307 (for POST)

The <to type="proxy">. I have not used it myself before, but it looks
like it does what you want it to do.

regards,
Wim


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Avlesh Singh  
View profile  
 More options Nov 5, 9:19 pm
From: Avlesh Singh <avl...@gmail.com>
Date: Fri, 6 Nov 2009 07:49:42 +0530
Local: Thurs, Nov 5 2009 9:19 pm
Subject: Re: redirect with status code 307 (for POST)

> I really don't see how I'm misreading it. I think you simply have it wrong
> in this case.

I'll try and put up a sample on the web today.

Cheers
Avlesh

On Thu, Nov 5, 2009 at 6:02 PM, Wim De Smet <krom...@gmail.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Wim De Smet  
View profile  
 More options Nov 6, 3:18 am
From: Wim De Smet <krom...@gmail.com>
Date: Fri, 6 Nov 2009 09:18:07 +0100
Local: Fri, Nov 6 2009 3:18 am
Subject: Re: redirect with status code 307 (for POST)
How about:
http://www.andypemberton.com/sandbox/prg/

I tried it with a 307. In firebug I'm seeing 2 POSTs and the required
browser behaviour (confirmation before second POST).

regards,
Wim


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Avlesh Singh  
View profile  
 More options Nov 6, 12:34 pm
From: Avlesh Singh <avl...@gmail.com>
Date: Fri, 6 Nov 2009 23:04:24 +0530
Local: Fri, Nov 6 2009 12:34 pm
Subject: Re: redirect with status code 307 (for POST)

You are right, Wim. The behavior turned out to be contrary to my belief and
understanding of the 307 status code. I tested it myself to verify. The only
problem is that command line agents (wget, curl etc) still don't "re-submit"
the post data to new url. This led to the misconception, I initially had.

I will shortly add a ticket to support this in the UrlRewriteFilter.

Cheers
Avlesh

On Fri, Nov 6, 2009 at 1:48 PM, Wim De Smet <krom...@gmail.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google