473,386 Members | 1,644 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Returning a "304 Not Modified" responce

The standard says "The 304 response MUST NOT contain a message-body,
and thus is always terminated by the first empty line after the header
fields"
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

So in my PHP script I do the time calculations and then I simply do:

header('HTTP/1.1 304 Not Modified') ;
exit ;

But when I retrieve the responce as raw text I see that the responce
does have a body. It is just 8 bytes of binary data and I dont know how
to prevent that from being sent after the headers.

Any idea??

Dec 17 '06 #1
8 4048

Hermann schrieb:
The standard says "The 304 response MUST NOT contain a message-body,
and thus is always terminated by the first empty line after the header
fields"
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

So in my PHP script I do the time calculations and then I simply do:

header('HTTP/1.1 304 Not Modified') ;
exit ;

But when I retrieve the responce as raw text I see that the responce
does have a body. It is just 8 bytes of binary data and I dont know how
to prevent that from being sent after the headers.
Do you have space, tabs or cr/lf somewhere before <? or after ?>. This
might get posted too.

In general, your header statement gets bigger, since it gets wrapped
inside a valid HTTP header.
I'm sure, you know.

Could you post the source of the header?

Dec 17 '06 #2
The PHP code I use is the following:
--------------------------------------------------------------------------------------------------
<?
$file=$_SERVER['QUERY_STRING'] ;
$fullFilePath=$_SERVER['DOCUMENT_ROOT'].$file ;
$fileModifiedTime=filemtime($fullFilePath) ;

if($_SERVER['HTTP_IF_MODIFIED_SINCE'])
{ $ifModifiedTime=strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'],0) ;
if($fileModifiedTime<=$ifModifiedTime)
{ header('HTTP/1.1 304 Not Modified') ;
exit ;
}
}
--------------------------------------------------------------------------------------------------

There is no closing php tag "?>", meaning that not a single byte is
sent to the client.
So I really dont know why are those few bytes being sent after the
headers.
They are just trash, just senseless 1s and 0s. They are always the same
4 bytes.

Dec 17 '06 #3
On 17 Dec 2006 12:31:08 -0800, "Hermann" <He*************@gmail.comwrote:
>They are just trash, just senseless 1s and 0s. They are always the same
4 bytes.
What bytes are they? They wouldn't happen to be a Unicode Byte Order Mark
(BOM) would they? This would likely not be shown in your editor.

--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Dec 17 '06 #4
Here is the complete responce.
Take a look:
http://img490.imageshack.us/img490/6226/dibujowc7.png

Dec 17 '06 #5
On 17 Dec 2006 13:33:22 -0800, "Hermann" <He*************@gmail.comwrote:
>Here is the complete responce.
Take a look:
http://img490.imageshack.us/img490/6226/dibujowc7.png
Oh well, so much for my theory then :-)

The partial string "....ecti....K.e" might have originally been "Connection:
Keep-Alive" in whatever memory location it came from, but that doesn't help
much.

--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Dec 17 '06 #6

Hermann schrieb:
Here is the complete responce.
Take a look:
http://img490.imageshack.us/img490/6226/dibujowc7.png
Hm, this doesn't look that bad. The 0d0a0d0a marks the end of the
header as expected.

Are you absolutely sure, that the additional bytes are really at the
end of the data? Or does your packet-sniffer always print full rows of
data?

In case you could post a sample URL, I'm happy to verify from over here.

Dec 18 '06 #7

Hermann schrieb:
Here is the complete responce.
Take a look:
http://img490.imageshack.us/img490/6226/dibujowc7.png
Oh, forgot to mention:

Since your HTTP reply doesn't contain a Content-length property like
this

Content-length: 327

it ends at the 0d0a0d0a. So, everything seems to be fine.

Dec 18 '06 #8
You are right. It actually seems to be working pretty well.

My HTTP sniffer always show complete rows so it is probably nothing to
worry about.

Thank you all for your replies.

Dec 18 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Skip Montanaro | last post by:
I updated the patch that supports PEP 304, "Controlling Generation of Bytecode Files" to apply cleanly against current CVS. I've tested it on Mac OS X (straight Unix build only). I'd appreciate...
235
by: napi | last post by:
I think you would agree with me that a C compiler that directly produces Java Byte Code to be run on any JVM is something that is missing to software programmers so far. With such a tool one could...
6
by: timbobd | last post by:
I have a Windows form that displays a database table in a DataGrid. When you click on a row, the row's values get copied to bound TextBoxes below, and when the "Save" button is clicked the database...
3
by: EYIII | last post by:
Is it possible to retrieve the "created by" identity and "modified by" identity for a file (e.g. word doc, .pdf, report, etc) using .NET?
2
by: wsnyder3 | last post by:
I have many forms but all the information is related to one another. I wanted to know if there was a way that if someone updates a account that it will show the last date modified on all the...
1
by: NevilleDNZ | last post by:
Hi, Apologies first as I am not a unicode expert.... indeed I the details probably totally elude me. Not withstanding: how can I convert a binary string containing UTF-8 binary into a python...
5
by: arnuld | last post by:
this is a programme that counts the "lengths" of each word and then prints that many of stars(*) on the output . it is a modified form of K&R2 exercise 1-13. the programme runs without any...
5
by: alex21 | last post by:
For my program i need a great deal of completely random, unique, 12 character id's. So i wrote these three functions public static string GiveUniqueID(IEnumerator id_key, int count) {...
2
by: bips2008 | last post by:
The code seems to work fine in other browser but in IE it throws this error. This is very urgent for me and any help would be greatly appreciated For your convienence i have posted the code for the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.