Please contribute

Coordinator
Feb 10, 2010 at 8:40 AM

I would be glad if someone could help me create headers and header parsers.

All headers can be found in the HTML specification: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14

 

Start with creating a class (all header classes should have Header as suffix: 'ContentTypeHeader') in the HttpServer.Headers namespace. It should derive IHeader and have a constant called NAME (capitalized header name).

The description from the HTML specification should be copied into the header.

 

Next thing to do is to create the parser. Create a class ('ContentTypeParser') in the HttpServer.Headers.Parser namespace and let it implement IHeaderParser. Add the ParserFor attribute, it will make the library automatically add the parser into the header factory.

ParserExample:

 

[ParserFor(ContentTypeHeader.NAME)]
public class ContentTypeParser : IHeaderParser
{
	public IHeader Parse(string name, ITextReader reader)
	{
		string contentType = reader.ReadToEnd(';');

		// got parameters
		if (reader.Current == ';')
		{
			HeaderParameterCollection parameters = HeaderParameterCollection.Parse(reader);
			return new ContentTypeHeader(contentType, parameters);
		}

		return new ContentTypeHeader(contentType);
	}
}

 

 

Feb 26, 2010 at 9:39 AM

Hi,

Do you still need the Coordinator?

Coordinator
Feb 26, 2010 at 9:54 AM

Contributions are still welcome.

Feb 26, 2010 at 10:07 AM
Hi jgauffin,
That sounds good. I would use my free time to help with you. Could you show me what I could do now?
Best wishes,
Peica Chen
Coordinator
Mar 2, 2010 at 8:56 AM

You can create more headers (check first message in this thread)