[En-Nut-Discussion] browser redirection with "Location:"
Jelle Martijn Kok
jmkok at youcom.nl
Mon Dec 15 13:00:49 CET 2003
Hi Dave,
> NutHttpSendHeaderTop(stream, req, 200, "Ok");
As far as I know "Location" headers should be sent by in combination with a
3xx Redirection status code. So I guess it should be:
NutHttpSendHeaderTop(stream, req, 302, "Found");
What you also should test is login with telnet and check if it exactly
generates the correct page.
eg:
telnet 192.168.1.101 80
GET /cgi-bin/test.cgi?Sound=Tone1 HTTP/1.0
(followed by 2 resturns...)
Jelle Martijn Kok
----- Original Message -----
From: "Dave Smart" <Dave at Smart-Family.net>
To: "EtherNut Discussion (E-mail)" <En-Nut-Discussion at egnite.de>
Sent: Saturday, December 13, 2003 2:35 AM
Subject: [En-Nut-Discussion] browser redirection with "Location:"
> I have a web page compiled into the file system which I based on the httpd
> sample - the many samples are terrific by the way!
>
> I proved by example on my PC web server that -
> print <<"EOM";
> Location: http://192.168.1.101/HWTest.htm
>
> EOM
> exit;
> will take me from the home PC to my Ethernut web server, as expected. I
> wanted to do something similar within the ethernut site, but can't get
this
> method to work, and I'm not sure why.
>
> Eventually, the fixed page in this example will be selected based on the
cgi
> parameters. I thought about opening the file of interest and sending it
> directly, but having both my code and the server code doing the same thing
> seemed wasteful, so I thought it more elegant to use the browser
redirection
> and let the server open and send the file.
>
> In more detail -
>
> On one of my web pages I configured several hardware tests, so there are
> links similar to <http://192.168.1.101/cgi-bin/test.cgi?Sound=Tone1>,
where
> the ip is that of the ethernut web server.
>
> When I click on this link, it is handled just as it should (even makes the
> noise it should). I then want it to refresh to the web page it came from,
so
> I may activate another of the tests. This is where I'm stuck.
>
> I tried several variations of -
>
> static prog_char redirect[] = "Location: http://%s/HWTest.htm\r\n\r\n";
>
> Like this -
> NutHttpSendHeaderTop(stream, req, 200, "Ok");
> NutHttpSendHeaderBot(stream, html_mt, -1);
> fprintf_P(stream, redirect1, inet_ntoa(confnet.cdn_ip_addr));
>
> and even this hardwired version -
>
> fputs_P("Location: http://192.168.1.101/HWTest.htm\r\n\r\n", stream);
>
> I did finally get it to work the round-about way -
>
> static prog_char redirect[] = "<html><meta http-equiv=\"Refresh\"
> content=\"0;URL=http://%s/HWTest.htm\"></head><body>Back to
> test.</body></html>";
>
> but it sits on this screen long enought to anoy me.
>
> Can you see what I'm doing wrong?
>
> Dave Smart
>
>
> _______________________________________________
> En-Nut-Discussion mailing list
> En-Nut-Discussion at egnite.de
> http://www.egnite.de/mailman/listinfo.cgi/en-nut-discussion
>
More information about the En-Nut-Discussion
mailing list