Http code that precedes the html tags

J

Judge Judy

What does the http code before the <HTML> tag look like?

I know that I can put cookies in the meta tags of the header block,
however when I try to put it before the <HTML> tag it does not work.
I don't understand what format the http code takes. There are
riduculous long winded RFCs on just the HTTP version (who reads or
writes this stuff), but none on how to send the HTTP to a browser.
 
G

Gus Richter

Judge said:
What does the http code before the <HTML> tag look like?

I know that I can put cookies in the meta tags of the header block,
however when I try to put it before the <HTML> tag it does not work.
I don't understand what format the http code takes. There are
riduculous long winded RFCs on just the HTTP version (who reads or
writes this stuff), but none on how to send the HTTP to a browser.


HTTP is the protocol used by the Browser (Client) requesting data to be
transfered to it from a Server which then answers back and sends the
data requested.

<http://searchwindevelopment.techtarget.com/sDefinition/0,,sid8_gci214004,00.html>
Hypertext Transfer Protocol:
<http://en.wikipedia.org/wiki/Http>

The Server sends the data to the Browser (Client) via packets using TCP/IP:
<http://en.wikipedia.org/wiki/Internet_protocol_suite>

The Data which the Server sends is the Web Page which you mention in
your posting with the reference of <html>.

HTML (HyperText Markup Language) in it's latest version is 4.01:
<http://www.w3.org/TR/html4/>
has specific rules for the structure of a W3C conforming HTML Document
(Web Page), like so:

There must be a Doctype Declaration.
<html>
<head>
contains permittted HEAD elements
</head>
<body>
contains permitted BODY elements
</body>
</html>

The only thing permitted before the <html> tag is the Doctype
Declaration, which normally should be this one:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

If you place a META element (which is only permitted to be in the head
section) outside of the head section as you say you did, then you should
not be surprised that things don't work.

You can only change HTTP within the browser software and/or within the
server software and there is no reason whatsoever for you to want to do so.
 
H

Harlan Messinger

Judge said:
What does the http code before the <HTML> tag look like?

I know that I can put cookies in the meta tags of the header block,
however when I try to put it before the <HTML> tag it does not work.
I don't understand what format the http code takes. There are
riduculous long winded RFCs on just the HTTP version (who reads or
writes this stuff), but none on how to send the HTTP to a browser.

You can't add HTTP headers by just inserting them in front of the HTML
tag. In the HTTP response (as in many other types of Internet protocols,
such as SMTP and NNTP), the headers are listed one after another, line
by line, and then an empty line is inserted after them and before the
body of the request. So once the client (the browser or whatever) has
seen that blank line, it no longer expects to see headers, and treats
everything after it as content.

Headers are configured in the web server. If you are using a server-side
programming technology, such as ASP, ASP.NET, or PHP, to generate your
HTML, then there will be a method you can call (before any content has
been sent to the client) to instruct the web server to add a desired
header to that page.
 
L

Lars Eighner

the said:
What does the http code before the <HTML> tag look like?

It doesn't matter because you cannot enter http headers in an html
document. Http headers have to be sent by the server and by the
time the first character of your html document is sent it is too late.

You can get the server to send some kinds of headers based on .htaccess
files --- when the server uses them. And when you --- if you --- generate
documents dynamically with CGI or a server preprocessing module, you can
indeed write headers for the server to pass on (and fortunately this is
often made easy by appropriate functions or APIs). But there is nothing
you can do in an html file.
I know that I can put cookies in the meta tags of the header block,
however when I try to put it before the <HTML> tag it does not work.

Because META is an HTML element, and of course it cannot occur before the
html starts (and for that matter, it has to be within the head element.
I don't understand what format the http code takes. There are
riduculous long winded RFCs on just the HTTP version (who reads or
writes this stuff), but none on how to send the HTTP to a browser.

Oh, boo-hoo, you might have to spend some time in library. Well, I'll
save you some trouble. You cannot do it in an html file. If CGI or
a preprocessor is enabled on you server, you can generate HTTP headers,
but you don't have to do endless research as most preprocessors will
have appropriate functions to do the nitty-gritty for you and ditto for APIs
for commonly used CGI languages.
 
J

Judge Judy

HTTP is the protocol used by the Browser (Client) requesting data to be
transfered to it from a Server which then answers back and sends the
data requested.

<http://searchwindevelopment.techtarget.com/sDefinition/0,,sid8_gci214004,00.html>
Hypertext Transfer Protocol:
<http://en.wikipedia.org/wiki/Http>

The Server sends the data to the Browser (Client) via packets using TCP/IP:
<http://en.wikipedia.org/wiki/Internet_protocol_suite>

The Data which the Server sends is the Web Page which you mention in
your posting with the reference of <html>.

HTML (HyperText Markup Language) in it's latest version is 4.01:
<http://www.w3.org/TR/html4/>
has specific rules for the structure of a W3C conforming HTML Document
(Web Page), like so:

There must be a Doctype Declaration.
<html>
<head>
contains permittted HEAD elements
</head>
<body>
contains permitted BODY elements
</body>
</html>

The only thing permitted before the <html> tag is the Doctype
Declaration, which normally should be this one:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

If you place a META element (which is only permitted to be in the head
section) outside of the head section as you say you did, then you should
not be surprised that things don't work.

You can only change HTTP within the browser software and/or within the
server software and there is no reason whatsoever for you to want to do so.


I think you misunderstood me. I followed the example on
http://en.wikipedia.org/wiki/HTTP_cookie

A server would set a cookie using the Http

HTTP/1.1 200 OK <= I don't know if I need this ??
Content-type: text/html
Set-Cookie: name=value; ....


I looked at other exampes and they did not include the
"HTTP/1.1 ... " line.

I tried with and without the HTTP line without sucess.



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

The HTML would put the cookie in the meta-tag

<HTML>
<head>
<meta http-equiv=Set-Cookie: name=value; ...... >

</head>

etc

I am able to generate a cookie from a static page, and I can create
and manage cookies using a javascript. I think managing cookies on
the client side cookies is very secure.
 
J

Jonathan N. Little

Judge said:
On Wed, 04 Feb 2009 04:37:28 -0500, Gus Richter



I think you misunderstood me. I followed the example on
http://en.wikipedia.org/wiki/HTTP_cookie

A server would set a cookie using the Http

HTTP/1.1 200 OK <= I don't know if I need this ??
Content-type: text/html
Set-Cookie: name=value; ....

This is what the webserver sends out in response to a request for your
page. You do not put this in your markup.
I looked at other exampes and they did not include the
"HTTP/1.1 ... " line.

They do for HTTP transactions, it's part of the protocol.
I tried with and without the HTTP line without sucess.

How? In your markup?

HTTP/1.1 200 OK
<html>
....

If so, of course if failed.
------------------------------------------------------------------------

The HTML would put the cookie in the meta-tag

<HTML>
<head>
<meta http-equiv=Set-Cookie: name=value; ...... >

</head>

etc

I am able to generate a cookie from a static page, and I can create
and manage cookies using a javascript. I think managing cookies on
the client side cookies is very secure.

This again, if it is managed client-side is can also be changed and
manipulated client-side, i.e., by the visitor not by you. Cookie
security depends on what is in the cookie and how it is managed
server-side. Putting sensitive information: passwords, account #, SSN,
etc. in cookies is a *very, very, very bad* idea. *Never* should be done.
 
R

richard

What does the http code before the <HTML> tag look like?

I know that I can put cookies in the meta tags of the header block,
however when I try to put it before the <HTML> tag it does not work.
I don't understand what format the http code takes. There are
riduculous long winded RFCs on just the HTTP version (who reads or
writes this stuff), but none on how to send the HTTP to a browser.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

It's not http or html. It is a page style declaration which helps
determine how the page is to be handled.

where you see 4.01 transitional can also be other types of page styles
such as strict.

www.w3.org
 
R

richard

You sound confused. What are you really trying to accomplish?


Well duhh. What is the one line of code that precedes the <html> tag?
doctype don't mean nuthin?
 
R

rf

richard said:
Well duhh. What is the one line of code that precedes the <html> tag?
doctype don't mean nuthin?

Before the <html> tag there may be a doctype.

Before that (or the <html> tag) there is a single empty line.

Before that are the HTTP headers.

Well duh. That is what the OP is talking about. The HTTP headers. That is
why she said "What does the http code before the <HTML> tag look like?."
 
G

Gus Richter

Judge said:
I think you misunderstood me. I followed the example on
http://en.wikipedia.org/wiki/HTTP_cookie

A server would set a cookie using the Http

HTTP/1.1 200 OK <= I don't know if I need this ??
Content-type: text/html
Set-Cookie: name=value; ....


I looked at other exampes and they did not include the
"HTTP/1.1 ... " line.

I tried with and without the HTTP line without sucess.


I believe that it is you that did not understand me. The html document
structure is (should be) as I said. The http header exchange between
browser/server is in the background which you have no access to
directly. When you introduce a cookie via meta (as in your example
below) or script (browser-side or server-side), it is added to the http
header automatically - you do not access the http header directly, as I
understood you to say.

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

The HTML would put the cookie in the meta-tag

<HTML>
<head>
<meta http-equiv=Set-Cookie: name=value; ...... >

</head>

etc

I am able to generate a cookie from a static page, and I can create
and manage cookies using a javascript. I think managing cookies on
the client side cookies is very secure.


Search using cookies and security as keywords and do a bit of reading.
 
D

dorayme

"rf said:
Before the <html> tag there may be a doctype.

Before that (or the <html> tag) there is a single empty line.

Can you say more about the need for the single empty line before a dd?
Is this something the server adds somehow or something that one should
have in ones html docs before loading up to a server? Is there some fine
point here that I need to know about?
 
R

rf

dorayme said:
Can you say more about the need for the single empty line before a dd?
Is this something the server adds somehow or something that one should
have in ones html docs before loading up to a server? Is there some
fine point here that I need to know about?

It's nothing you need to worry about. It's to seperate the HTTP response
headers from the response body (the bit you know of as an HTML page). The
headers have to go in the TCP/IP message somewhere. They go at the front of
the message, followed by a empty line, followed by your HTML.

The headers are usually put there by the HTTP server. You can, however,
cause different headers to be sent using, for example, PHP. Once again
though you don't need to worry about where those headers are.

Here is a picture of a HTTP request made using telnet:

http://en.wikipedia.org/wiki/File:Http_request_telnet_ubuntu.png

You can also look at the headers using firebug, the net tab, expand the GET.
Firebug helpfully seperates the headers from the response body (remember the
empty line delimiter) and presents them in two seperate tabs.

Similar stuff happens with email and usenet. Cause your newsreader to
display a raw NTTP message. You will see the NTTP headers, an empty line and
then the actual message.
 
D

dorayme

"rf said:
...It's to seperate the HTTP response
headers from the response body (the bit you know of as an HTML page). The
headers have to go in the TCP/IP message somewhere. They go at the front of
the message, followed by a empty line, followed by your HTML.

Righto. I see.
 

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,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top