How to redirect from POST to Get? - html

I have an HTML Page A that receives a POST method from a third-party server.
I would like to redirect Page A immediatly to Page B using GET Method. (For some other technical reasons the third-party server cannot communicate directly with page B...)
Is there any way to redirect from the POST Method on Page A to GET in Page B ? I don't care about parameters to be redirected...
I tried the following :
Add "Location" header in the POST response : Doesn't work.
Add the following javascript in Page A : Basically when Page A is loaded, it redirects
to Page B. It works but not very elegant.
<script>window.location.href = "http://stackoverflow.com";</script>
I was wondering if there is a better way to do that please ?
Thanks.

Thanks #Evert.
The answer is :
Add "Location" header in the POST response with 301 HTTP code.

Related

301 or 303 redirect in html meta tag?

Recently I have moved my content from oldURL to newURL and I want to attain 301 redirect(document moved permanently), to achieve that I have used new html appology page with meta tag having the new url and http-equip="Refresh", something like follows;
<meta http-equiv="Refresh" content="0; url="newURL" />
I want to know that, will it return status code 301 or status code 303 ?
Also, if it is 303, please suggest me any better way that how should I achieve 301 redirect.
Thanks in advance.
I want to know that, will it return status code 301 or status code 303 ?
No. Meta elements in an HTML document are not handled at the HTTP level.
The HTTP status will be whatever the HTTP headers say (probably 200).
Use HTTP for redirects, not Meta.
You can do one of these two solutions. You can either :-
Create an htaccess file redirecting you to the new URL. There's more on how to do the task mentioned above here.
You can create a small error template in your old URL stating that it has been moved and post the link to your new URL.
In my opinion, I would recommend you doing the former because the user will not know the transition between pages.

Google Chrome show ajax response

I am using Google Chrome Developer Tools to try to see the response of some AJAX url's.
The problem is that when I click on the NETWORK TAB, then on the link, then on RESPONSE, I see this text : "THIS REQUEST HAS NO RESPONSE DATA AVAILABLE".
I have been using FIREBUG and I am 100% sure there is a response from that page.
Can somebody help with this ?
Thank you !
You can try manually checking if there's a response or not
So, generally when dealing with ajax, in most cases we use the POST, You can create a 'same structured' page to handle same input/response but using Get method and print the output data as normal.
This way you can see if there's any response/errors in your script very easily

Get page size without downloading

Although i don't think it's possible but is it a way to get a page size without downloading it?(it's seems silly but anyway i wanna ask it here)
you can curl a page and get it's size but i don't want to dl the page and also there is nothing interesting in the header with text/html.
Query the Content-Length property from the page header.
As defined by Section 14.13 of the Hypertext Transfer Protocol Documentation.
Use the HEAD HTTP method instead of GET:
The HEAD method is identical to GET except that the server MUST NOT return a message-body in the response. The metainformation contained in the HTTP headers in response to a HEAD request SHOULD be identical to the information sent in response to a GET request. This method can be used for obtaining metainformation about the entity implied by the request without transferring the entity-body itself.
Even making a HEAD request doesn't guaranty u will get content-length in the output. check it for yourself:
stream_context_set_default(
array(
'http' => array(
'method' => 'HEAD'
)
)
);
var_dump(get_headers("http://www.stackoverflow.com", 1));
var_dump(get_headers("http://www.google.com", 1));
var_dump(get_headers("http://php.net/", 1));
I think the best option is still to go and dl the page using curl and then see what's the size(pure text) of the page

problem to get the Referer page

I'm trying to get the referer page, but i have a problem , sometimes i get bad the referer page,
for example:
i have 3 pages, when the page 1 link to page 2 , and the page 2 make a process and after redirect to page 3, so when i try to get the referer page in the page 3, i get the page 1 and not the page 2,
I think that the problem is the page 2 this page doesn´t show anything to the user, is only a page who make a procedure.
Do you have any idea how i can to get the referer page correctly??
Thanks.
I'm using TCL with openacs
It's difficult to answer without knowing exactly what you're trying to do. If page 2 is only calling a procedure, what about putting the contents of page 2 into an ad_proc, and then calling that proc in page 3? Or can page 2 redirect to other places when it is finished?
If you give more info, I'm sure I can help. The normal way I would pass referer info in OpenACS is to use a variable called return_url, which I pass from one page to the next as a hidden form element. There are lots of examples of that in OpenACS. Alternatively you could use ad_set_client_property to store it on page 1 and then on page 3 use ad_get_client_property to read it.
Thanks to everyone,
I already solve my problem using the < meta HTTP-EQUIV="REFRESH" content="0; url=page3" >, but in openacs there is a function that do it.
I relplace the
ad_returnredirect
by
util_ReturnMetaRefresh
so in this way i already can read the correct referer page
how are you sending the user from page 2 to page 3? with php:
enter code hereheader("location:")
or html redirect?
if you are using header("location:") it will probably not work. try using html redirect like
<meta HTTP-EQUIV="REFRESH" content="0; url=page3">

How to get result back from CGI(C) to the same HTML page?

Can I display the result which is processed in the CGI(using C) on the same html page, from where the CGI is invoked?
Regards,
MalarN
No, HTTP does not work that way.
You would have to make a asyncronious request (using JavaScript, this is commonly known as AJAX) instead.
In a nutshell, you can spawn a background HTTP request to your CGI process, instead of posting the browser to it in the main HTTP request.
See this: http://en.wikipedia.org/wiki/XMLHttpRequest