xp-framework/xp-framework — pull request #203 by pdietz (2012-11-14 08:01:57+00:00)
Title: HeaderFactory

Hi,

This adds a HeaderFactory to take away the need of hardcoding HTTP headers every know and then and thus removing/limiting possible syntax errors and taking away complexity.
Additionally this adds some more error checking possibilities, like indication if:
- Header is unique or may appear several times
- Header is request only
- Header is response only

Also for content based Headers some values may be automatically set, if the content is given, so no more need to set/calculate the content length or md5 sum, just hand over the content itself and the rest is done for you.
This might eventually be extended to guessing content type + charset and/or encoding.
It might even be somehow used in the Content-Range headers start, end and max values.

With the introduction of specific headers, you now also have the possibility for validation of values (e.g. charset, authentication, urls numbers/strings) and/or automated formatting (e.g. dates).
I'm not doing any validation so far in the headers I implemented.

The headers should be extended to all standard headers by the time.
Since the type required to load a header can be evaluated by XPClass:forName() adding custom headers is easy.

Best regards,
Philipp