Hi Atul,
It’s good we reached 100 tests already! I guess that we’ll soon be at 1000 ;-) and we will have learnt a lot more about unit testing and will be writing extremely high quality tests ;-)!
It’s really great to exchange ideas by means of patches and tests. In your latest patch I see something I never thought about – namely, validation of header values. I always thought of Header as a very thin wrapper around the raw header bytes but it makes perfect sense to put some more functionality there.
The phases of header parsing are:
- identifying header fields (which could be split over multiple lines) in parse()
- parsing the header filed name and values for each header field parseLine()
The derived classes can override parseLine() so that the status or request lines can be parsed in a special way.
I think we should add a third phase that validates the parsed values for each header. Of course the derived classes should be allowed to override the validation rules for some of the header fields. I think that there would be a clever way to say, maybe in a table
“Content-Length” allows single value that is an unsigned integer
“Content-Language” allows multiple values from the set of language ids
“Content-Location” in a single URI
… and so on.
I have one concern about interoperability… it may happen that Calitko or the other party it communicates with has a bug that caused the validation of a single header field to fail although everything else is correctly parsed. We would discard the data just because some unimportant header field has incorrect value. We should be strict when generating our output but tolerant when parsing input form others. What I mean is that:
m_p = makeNewHeader("Content-Language : xxxxxxxxxxxx");
CPPUNIT_ASSERT (m_p->isValid() == false);
should still render the header as valid because the other values might be correct. What do you guys think about that? Atul is right that we should be careful not to overdo things…
Btw. I pushed your patch in revno 92 of your public branch.
Regards,
Peter
atul wrote:Hi all
Here are some more tests .. Some of them fail and AFAIK they should pass ( as per the HTTP RFC doc ).
Do we need all these tests? Like
void testLastModified()or am I overdoing this stuff?
Let me know..
— cheerio atul
