By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,776 Members | 1,246 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,776 IT Pros & Developers. It's quick & easy.

How to modify the Request-Line ?

P: n/a
Is it possible to modify the Request-Line of an HTTP response ?
I'd like to remove the parameters from a GET url.

More precisely, I wish I could replace :
[From Req: GET /myuri?key1=val1 HTTP/1.1]
with :
[From Req: GET /myuri HTTP/1.1]
The "Header" function doesn't seem to allow this.

Thanks.

Jul 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
patrice wrote:
Is it possible to modify the Request-Line of an HTTP response ?
I'd like to remove the parameters from a GET url.


If I'm not mistaken, the Request-Line is in the incoming HTTP request,
not the response.

What would be the point in altering it once it's arrived? If you don't
want to use the GET parameters, then don't!

Or am I misunderstanding you?

--
Oli

Jul 17 '05 #2

P: n/a
patrice wrote:
Is it possible to modify the Request-Line of an HTTP response ?
I'd like to remove the parameters from a GET url.

More precisely, I wish I could replace :
[From Req: GET /myuri?key1=val1 HTTP/1.1]
with :
[From Req: GET /myuri HTTP/1.1]
The "Header" function doesn't seem to allow this.


This is usually done through a Location: header, which is received by the
browser and translated into a new GET request with the URL defined by this
header. Example:

<?php

if ($_REQUEST['QUERY_STRING']) {
header("Location: http://mysite.com/myuri/");
exit;
}

?>
JW

Jul 17 '05 #3

P: n/a
My aim is as follow : I want to use a form and a javascript
location.replace() together, in order to replace the curent page in the
browser's history list.
So I'm forced to use the GET method (there doesn't seem to be a way to
achieve this through location.replace when using the POST method).
But when using GET, the parameters will appear at the end of the URL
displayed in the client's browser, which I don't want. This URL is the
one returned by the server's response and could be different from the
one appearing in the request (I need to check this however). So if I
could remove the parameters from the Request-Line sent to the client,
it would be OK : the client wouldn't see the parameters in the url but
I still could use the GET parameters through $_GET for instance.
I cannot use a :
header("Location: http://mysite.com/myuri/");
exit;

because it works differently ; it first sends the new location to the
client which then requests the new page. It costs a second
request-response exchange. Further more, in [From Req: GET
/myuri?key1=val1 HTTP/1.1], the key1=val1 is a true parameter, not an
url. I'm not interested in doing on the fly url translation.
Removing the parameters from the url with Apache's rewriting module
wont do it neither, because PHP would in this case never receive the
parameters.
So modifying the request-line with PHP - if possible - is the only
solution I've found till now.

Patrice

Jul 17 '05 #4

P: n/a
patrice said the following on 05/06/2005 08:43:
My aim is as follow : I want to use a form and a javascript
location.replace() together, in order to replace the curent page in the
browser's history list.
Why? Sites that try to take control of the user's browser are usually
just a pain in the arse.

Plus if the user has JS disabled, your page won't work at all...
So I'm forced to use the GET method (there doesn't seem to be a way to
achieve this through location.replace when using the POST method).
But when using GET, the parameters will appear at the end of the URL
displayed in the client's browser, which I don't want. This URL is the
one returned by the server's response and could be different from the
one appearing in the request (I need to check this however). So if I
could remove the parameters from the Request-Line sent to the client,


As I've already said, the Request-Line is *not* part of the server's
HTTP response, but part of the client's (browser's) HTTP request.

The only time the server sends back a URL (that appears in the browser)
in an HTTP response is in a Location header.

--------------------

Off the top of my head, the only way that I could see to do this (and
it's messy), is:

* Do the location.replace(), with the form variables in the GET string.

* Then have the server collect up all the submitted $_GET variables and
dump then in $_SESSION.

* Do a header("Location: http://example.com/simple_url/") redirect.

* At the new location, pick up the variables from the $_SESSION variable.

This is untested.
--
Oli
Jul 17 '05 #5

P: n/a
Oli Filth wrote :
As I've already said, the Request-Line is *not* part of the server's
HTTP response, but part of the client's (browser's) HTTP request.


I was mislead by the results of HTTP Interceptor (which adds the
Request-Line in the response to track messages more easily).

Sorry for all this.

Thanks.

Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.