Re: Sending a different protocol header

2003-09-09 Thread Chris Shiflett
--- Geoffrey Young [EMAIL PROTECTED] wrote:
 btw, can you please explain what ICY is for me?

I believe ICY is a protocol used for streaming media, so these headers are
probably an extension of HTTP that can be used instead of the pure ICY
protocol. That's a guess, anyway. :-)

Chris

=
Become a better Web developer with the HTTP Developer's Handbook
http://httphandbook.org/


Re: The best place for mod_perl beginners to get started.

2003-01-15 Thread Chris Shiflett
--- Geoffrey Young [EMAIL PROTECTED] wrote:
 and don't forget about the cookbook
 
http://www.modperlcookbook.org/

Speaking of that, why is it missing from
http://perl.apache.org/?

Chris



RE: use http-equiv to refresh the page

2002-11-06 Thread Chris Shiflett

  I just wanted to mention that the meta tag as well as its http-equiv
  attribute are both official parts of the HTML standard and have been
  for quite some time.

 Yes and no.

Well, I disagree with the no. I will explain it again below.

 HTML 4.0 has a section on META and http-requiv. In it, it mentions that
 \Some user agents support the use of META to refresh the current page
 after a specified number of seconds, with the option of replacing it by a
 different URI.\ and proceeds with an example. That sounds more advisory
 than part of the standard. But for the sake of argument, let\'s say it\'s part
 of the standard, and check what HTML 4.01 has to say.

 HTML 4.01 also has a section on META and http-requiv. However, the only
 reference to \refresh\ is: \Note. Some user agents support the use of
 META to refresh the current page after a specified number of seconds, with
 the option of replacing it by a different URI. Authors should __not__ use
 this technique to forward users to different pages, as this makes the page
 inaccessible to some users. Instead, automatic page forwarding should
 be done using server-side redirects.\

 I\'m guessing this is because http-equiv is designed to hold an HTTP
 header, but there is no such thing as an \Refresh\ header in HTTP.

No, there is an HTTP header called Refresh, and it is standard. The meta tag and the 
http-equiv attribute of the meta tag are also standard. However, some people seem to 
be confusing HTTP and HTML here for some reason. Refresh is an HTTP standard, while 
the meta tag is HTML. The http-equiv attribute of the meta tag allows some HTTP 
headers to be specified in the HTML. While this feature offers little to mod_perl 
developers who can manipulate the headers themselves anyway, it was historically very 
helpful to developers for providing accurate HTTP headers such as Expires when they 
could not otherwise do this.

The reason for that warning in the HTML specification is due to what the W3C likely 
considers a rampant abuse of the Refresh header which was not intended for redirection 
but only for refreshing the current resource. They are not warning against Refresh 
alone but rather what they consider a misuse of Refresh. The key phrase is, \with the 
option of replacing it by a different URI.\ This is what is frowned upon, not the 
meta HTML tag nor the Refresh HTTP header.

 So http-equiv=\refresh\ is no longer standard. Of course, this is all
 theoretical. In practice, too many people are not easily swayed by a
 measily thing such as a standard.

Right, and this was my second point in an earlier message. Support for this rogue 
feature is pretty widespread, though it should not be completely trusted. As one of 
the other posters pointed out, there are Web clients that do not support the use of a 
meta tag for redirection, but many (possibly most) do. It is quite common to see the 
use of a meta tag for redirection accompanied by instructions on the screen and a link 
for users that are not automatically redirected. By accomodating the users who are not 
automatically redirected, you can eliminate the possibility of a dead-end.

Of course, I hope that mod_perl developers always choose manipulating the real HTTP 
headers over the use of the http-equiv attribute of the meta tag. Also, it seems 
possible that there might be much wider support for redirection with the real Refresh 
HTTP header than for the meta tag equivalent. I know of at least one attempt to test 
and document support for this specific use:

http://www.hixie.ch/tests/evil/mixed/refresh1.http.html

Perhaps the results of this test can help a developer determine whether this misuse of 
the Refresh header is appropriate for a certain situation.

Chris



Re: use http-equiv to refresh the page

2002-11-05 Thread Chris Shiflett

  Is using meta tag a \bad\ approach?

 Yes.  It\'s something that Netscape added to their browser, which others 
 may or may not add to their browsers.  It\'s not part of any HTTP spec 
 and isn\'t guaranteed to work, even on totally correct web browsers.

A meta tag is not something unique to Netscape nor the least bit uncommon. It is 
supported by all major Web browsers and has been for quite some time. While its use 
may be discouraged over a protocol-level redirect at times, it is appropriate for some 
situations and appears to be appropriate for what the original poster is trying to 
accomplish.

As with any other HTML tag, the meta tag does not need to be part of an HTTP 
specification in order to be valid. Also, it is guaranteed to work on any compliant 
Web browser. HTML has its own specification, and the latest version describes the meta 
tag here:

http://www.w3.org/TR/html4/struct/global.html#h-7.4.4.2

Sorry for disagreeing like this, but I am always afraid to see people being given 
incorrect information that might cause them difficulty. I hope this helps clarify.

Chris



Re: use http-equiv to refresh the page

2002-11-05 Thread Chris Shiflett
Perrin Harkins wrote:


Chris Shiflett wrote:


http://www.w3.org/TR/html4/struct/global.html#h-7.4.4.2


Look a little further down that page:

/*Note.* Some user agents support the use of META 
http://www.w3.org/TR/html4/struct/global.html#edef-META to refresh 
the current page after a specified number of seconds, with the option 
of replacing it by a different URI. Authors should *not* use this 
technique to forward users to different pages, as this makes the page 
inaccessible to some users. Instead, automatic page forwarding should 
be done using server-side redirects./

I might be overzealous about this, but I dislike seeing HTTP-EQUIV 
meta tags used when actual HTTP headers are available to do the same 
thing. It's fine if there's a reason for it, but usually people do it 
because they don't realize they can just send a real header instead..


No, I actually agree with you completely on that last bit and am of the 
opinion that using the http-equiv attribute is a leftover habit from the 
early days of Web development when manipulating HTTP headers was not as 
convenient as it is now.

I just wanted to mention that the meta tag as well as its http-equiv 
attribute are both official parts of the HTML standard and have been for 
quite some time. Netscape also introduced things like cookies and SSL, 
but that should in no way discredit the technology.

The W3C's stance on refresh is the same for the header as well as the 
meta tag: they did not originally intend for it to be used to specify a 
*different* URL as a rudimentary method of redirection. They meant it to 
be used to refresh the current resource only. However, this rogue 
practice of redirection is quite common with both the header and the 
meta tag and is very well supported by browsers. In fact, I am not aware 
of any Web client that supports refresh but also limits the URL to the 
current resource only.

It is also the only option for the pause, then redirect behavior the 
original poster desired that I can think of.

Chris



Re: redirection halts if a message is printed

2002-11-04 Thread Chris Shiflett
Sumitro Chowdhury wrote:


Case I ( simple redirection ):
--
package redirect.pm

use Apache::Const -compile =
qw(HTTP_MOVED_TEMPORARILY);

sub handler (
  my $r = shift;
  $r-content_type('text/html');
  $r-headers_out-{'Location'}=
http://new.location;;
  return HTTP_MOVED_TEMPORARILY;
}
1;

Result is : browser immediately loads the new page.

Case II ( Print a message before redirection )
--
package redirect.pm

use Apache::Const -compile =
qw(HTTP_MOVED_TEMPORARILY);

sub handler (
  my $r = shift;
  $r-content_type('text/html');
  print Redirecting to new site ...;
  $r-headers_out-{'Location'}=
http://new.location;;
  return HTTP_MOVED_TEMPORARILY;
}
1;

Result is : Instead of opening the new URL, the
following is displayed on the browser :
Redirecting to new site ...
Ok
The document has moved here (here is clickable).
...

My question is : 
a)What is the reason for this behaviour ? Why does
printing a message halt the redirection ?
b)What needs to be done to display a message saying
Redirecting .. and then the browser to auto-display
the new URL ?


a. When your script outputs something (sending a message as you say), 
you are telling Apache that you are finished sending the HTTP headers 
and have begun the content part of the response. Thus, it is too late 
for the Location header you later want to send. This is a protocol 
restriction based on the construction of an HTTP message. To avoid this, 
you have to either send all of your HTTP headers first (my preference), 
or you need to buffer your output until you are finished sending your 
headers.

b. It sounds like you are wanting the user to visit an intermediate page 
displaying a Redirecting ... message before being forwarded to a final 
destination. In this case, you probably want to use HTTP's Refresh 
header or the HTML equivalent: meta http-equiv=refresh value=???. 
Both have the same syntax:

3; url=http://example.org/

In this example, the 3 is the number of seconds you want the client to 
wait prior to sending the next request, which will be for the URL 
http://example.org/.

Chris