get or post?

S

Scott Sauyet


No.

At least, assuming you're discussing doing this from Javascript in a
web browser. For any POST you perform, the server could send a
redirect to a GET.

If you have control on the server-side, you could echo the request
type into a JS variable; in PHP it might be

var httpMethod = "<?php echo $_SERVER['REQUEST_METHOD']; ?>"

Good luck,

-- Scott
 
T

Thomas 'PointedEars' Lahn

Scott said:
^^^^
No.

At least, assuming you're discussing doing this from Javascript in a
web browser. For any POST you perform, the server could send a
redirect to a GET.

If you have control on the server-side, you could echo the request
type into a JS variable; in PHP it might be

var httpMethod = "<?php echo $_SERVER['REQUEST_METHOD']; ?>"

See, there is a way :)


PointedEars
 
T

The Natural Philosopher

Thomas said:
Scott said:
Thomas said:
Is there a way to know if the current page is a result of a get or
post?
Yes.
^^^^
No.

At least, assuming you're discussing doing this from Javascript in a
web browser. For any POST you perform, the server could send a
redirect to a GET.

If you have control on the server-side, you could echo the request
type into a JS variable; in PHP it might be

var httpMethod = "<?php echo $_SERVER['REQUEST_METHOD']; ?>"

See, there is a way :)
Right little humourist, is our resident elf...;-)
 
E

Evertjan.

Thomas 'PointedEars' Lahn wrote on 25 jan 2010 in comp.lang.javascript:
Scott said:
Thomas said:
Is there a way to know if the current page is a result of a get or
post?
Yes.
^^^^
No.

At least, assuming you're discussing doing this from Javascript in a
web browser. For any POST you perform, the server could send a
redirect to a GET.

If you have control on the server-side, you could echo the request
type into a JS variable; in PHP it might be

var httpMethod = "<?php echo $_SERVER['REQUEST_METHOD']; ?>"

See, there is a way :)

No there is not.

The new page can never know if the page request is
1 a result of a bona fide form-get
or
2 just from a link contaning an URL with querystring.

You can never know if the page request is from a
form-post just if it tests positive a querystring
as this could be contained in the form post action='...?a=b'.
 
S

Scott Sauyet

The new page can never know if the page request is
1 a result of a bona fide form-get
or
2 just from a link contaning an URL with querystring.

I'm not sure that is a meaningful distinction. At the HTTP level,
both are GET requests, so even the server doesn't distinguish this.

-- Scott
 
E

Evertjan.

Scott Sauyet wrote on 25 jan 2010 in comp.lang.javascript:
I'm not sure that is a meaningful distinction. At the HTTP level,
both are GET requests, so even the server doesn't distinguish this.

No, they could also be POST requests at ther same time.

If you define a GET request als if without a querystring,
the whole OQ is meaningless.

The only interesting Q is if there is POST content
and if there is querytring content.
 
E

Eric Bednarz

Evertjan. said:
Thomas 'PointedEars' Lahn wrote on 25 jan 2010 in comp.lang.javascript:
Scott Sauyet wrote:
[OP, ed.]
Is there a way to know if the current page is a result of a get or
post?
var httpMethod = "<?php echo $_SERVER['REQUEST_METHOD']; ?>"

See, there is a way :)

No there is not.

I read that as wanting to know the request method, and I would think
that a HTTP server cannot resolve a resource and send response headers
without knowing that.

I wonder what you read.
 
E

Eric Bednarz

Evertjan. said:
Scott Sauyet wrote on 25 jan 2010 in comp.lang.javascript:


No, they could also be POST requests at ther same time.

I would like an example of an HTTP request that simultaneously uses the
HTTP GET and POST methods.
 
E

Erwin Moller

Eric Bednarz schreef:
I would like an example of an HTTP request that simultaneously uses the
HTTP GET and POST methods.

Here is one:

<form action="whatever.php?id=12" Method="POST" name="testform">
Firstname: <input type="text" name="firstname">
<input type="submit">
</form>

Then from PHP (whatever.php):
-------------------------------
<pre>
GET contains:
<?php
print_r($_GET);
?>
POST contains:
<?php
print_r($_POST);
?>
</pre>
-------------------------------

It is a bit weird I admit, but it works just fine.


Regards,
Erwin Moller

--
"There are two ways of constructing a software design: One way is to
make it so simple that there are obviously no deficiencies, and the
other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult."
-- C.A.R. Hoare
 
S

Scott Sauyet

Eric Bednarz schreef:
I would like an example of an HTTP request that simultaneously uses the
HTTP GET and POST methods.

Here is one:

<form action="whatever.php?id=12" Method="POST" name="testform">
Firstname: <input type="text" name="firstname">
<input type="submit">
</form>
[ ... ]
It is a bit weird I admit, but it works just fine.

Well, this still is an HTTP POST request. PHP interprets the query
string of the URL as GET variables, but it is not a GET request.

-- Scott
 
E

Evertjan.

Eric Bednarz wrote on 26 jan 2010 in comp.lang.javascript:

Here you skip the explanation of the above "no ..."
I read that

my sentence?
as wanting to know the request method, and I would think
that a HTTP server cannot resolve a resource and send response headers
without knowing that.

What HTTP-server [is there such an animal?]?

What Resource?

Why should a server without serverside programming ability [if that is what
you mean by HTTP-server], do anything with the POST content of the request
header?
and send response headers without knowing that.

The request querystring has no special request or response headers.

The POST content is in the request header, not in the response header.

I think!!!
I wonder what you read.

Where? In the Header?
 
E

Evertjan.

Scott Sauyet wrote on 26 jan 2010 in comp.lang.javascript:
Eric Bednarz schreef:
I would like an example of an HTTP request that simultaneously uses the
HTTP GET and POST methods.

Here is one:

<form action="whatever.php?id=12" Method="POST" name="testform">
Firstname: <input type="text" name="firstname">
<input type="submit">
</form>
[ ... ]
It is a bit weird I admit, but it works just fine.

Well, this still is an HTTP POST request. PHP interprets the query
string of the URL as GET variables, but it is not a GET request.

So we should define a GET request in the OQ sense just as a any request
that is not a HTTP POST request [disregarding the HEAD request which has no
clientside coding ability]?

You could do that, but what would be the use for the OP?
 
S

Scott Sauyet

Scott Sauyet wrote on 26 jan 2010 in comp.lang.javascript:
On Jan 26, 5:55ÿam, Erwin Moller
Well, this still is an HTTP POST request.  PHP interprets the query
string of the URL as GET variables, but it is not a GET request.

So we should define a GET request in the OQ sense just as a any request
that is not a HTTP POST request [disregarding the HEAD request which has no
clientside coding ability]?

No, but there is a specific verb given in the HTTP specification that
is used for each request. If that request responds with a page, there
is no client-side way from that page to know what verb was used; of
course additional server-side help can easily be supplied. That's
what I said in my original response.
You could do that, but what would be the use for the OP?

I don't know what the OP needs, but if it's to know, for instance,
that the current page is in response to a POST request, I believe that
this is not possible in general without server-side help.

-- Scott
 
E

Eric Bednarz

Evertjan. said:
Eric Bednarz wrote on 26 jan 2010 in comp.lang.javascript:

my sentence?

The OP’s question:

| Is there a way to know if the current page is a result of a get or
| post?
What HTTP-server

I don’t know which HTTP server the OP uses. :)
What Resource?

The resource that tentatively wants to know if it is a result of a GET
or POST request.
Why should a server without serverside programming ability [if that is what
you mean by HTTP-server],

By HTTP server I mean a server that services HTTP requests.
do anything with the POST content of the request
header?
¿Que?


The request querystring has no special request or response headers.

I think that this might be a pretty silly discussion.
The POST content is in the request header,

I thought that POST data is send in the message body of the request.
not in the response header.

I should better just have written ‘a response’.

The request method is stated in the request header, and is hopefully
accessible by server-side script (e.g. by the already mentioned
REQUEST_METHOD environment variable). Both response header and message
body may or may not depend on it.
 
T

The Natural Philosopher

Evertjan. said:
Thomas 'PointedEars' Lahn wrote on 25 jan 2010 in comp.lang.javascript:
Scott said:
Thomas 'PointedEars' Lahn wrote:
Is there a way to know if the current page is a result of a get or
post?
Yes. ^^^^
No.

At least, assuming you're discussing doing this from Javascript in a
web browser. For any POST you perform, the server could send a
redirect to a GET.

If you have control on the server-side, you could echo the request
type into a JS variable; in PHP it might be

var httpMethod = "<?php echo $_SERVER['REQUEST_METHOD']; ?>"
See, there is a way :)

No there is not.

The new page can never know

anythinmg. new pages are not intelligent, nor even computing engyns

Straw man. The ELF shot you.
 
T

The Natural Philosopher

Scott said:
I'm not sure that is a meaningful distinction. At the HTTP level,
both are GET requests, so even the server doesn't distinguish this.

It does
 
T

The Natural Philosopher

Eric said:
I would like an example of an HTTP request that simultaneously uses the
HTTP GET and POST methods.

I do it somewhat regularly..

VERY possible with javascript.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,525
Members
44,997
Latest member
mileyka

Latest Threads

Top