Re: Redirecting a multipart/form-data POST request

2001-01-16 Thread Darren Stuart Embry

On 2001-01-15, Ask Bjoern Hansen [EMAIL PROTECTED] wrote:

  When I do neither, i.e., leave the POST request as is and use
  the standard redirect mechanism, the browser hangs and the
  server actually does not send the redirect until I hit the Stop
  button (I'm using ngrep to determine this).  This also happens
  if I use the $r-print($header) method and still return
  REDIRECT.

 Try adding 
 
 $r-method('GET');
 $r-headers_in-unset('Content-length');
 
 to your code before doing the return REDIRECT.

Ask Bjoern, I privately replied to you on this as well.

I should have been more clear and said I was doing exactly this,
as per [1], when I mentioned I was converting POST requests to
GET requests.

This is so that I could get redirects to work in response to a
urlencoded POST request using the standard redirection technique
of setting the Location header and mime type and returning
REDIRECT instead of manually constructing and $r-print()ing a
header.

In any case, [1] does me no good with multipart/form-data which
is what I was asking about in the first place.

Darren

[1] http://perl.apache.org/guide/snippets.html#Convert_a_POST_Request_into_a_GE

-- 
Darren Stuart Embry.  A whole roasted almond in every piece!
http://www.webonastick.com/
``To undo most things in Excel, click the undo button.''
  -- Actual ToolTip from Microsoft Office 97



Redirecting a multipart/form-data POST request

2001-01-15 Thread Darren Stuart Embry

I am writing a program that needs to process form data, (here's
the kicker) which is sometimes multipart/form-data, then
redirect a user to a GET request (which doesn't need to process
the form data).  I would like to use the standard mechanism for
issuing a redirect, for other reasons:

$r-header_out('Location' = $url);
return REDIRECT;

I have discovered two ways to achieve redirects from a POST
request if its content is application/x-www-form-urlencoded:

- $r-print() the headers manually and have the handler return
  DONE or HTTP_OK.  This nasty hack is what I am doing at this
  time so I can get redirects from multipart/form-data to
  somehow work.

- convert the POST request to a GET and redirect the standard
  way.  I don't understand why forcing a read of all the data
  coming in from the HTTP request allows redirects to work, but
  it does.

When I do neither, i.e., leave the POST request as is and use
the standard redirect mechanism, the browser hangs and the
server actually does not send the redirect until I hit the Stop
button (I'm using ngrep to determine this).  This also happens
if I use the $r-print($header) method and still return
REDIRECT.

The second method allows me to revert to the use of the default
redirect mechanism, but unfortunately does not work with
multipart/form-data.  I would *really* like to be able to use
the standard redirection mechanism for other reasons.  From the
Apache man page:

   $r-content
   The $r-content method will return the entity body
   read from the client, but only if the request content
   type is `application/x-www-form-urlencoded'.
   ...

Is there a similar technique I can use to read all the
multipart/form-data from the socket and then allow CGI.pm to
continue to process it, and would this work?

Thank you,
Darren

-- 
Darren Stuart Embry.  Kicking down some kind examples of how to keep
your karma clean.  http://www.webonastick.com/
``I base most of my fashion taste on what doesn't itch.''
--- Gilda Radner