[En-Nut-Discussion] uHTTP library One more questions
Harald Kipp
harald.kipp at egnite.de
Thu Sep 13 11:16:45 CEST 2012
Hi Ole,
On 12.09.2012 14:18, Ole Reinhardt wrote:
> When I call
>
> StreamClientAccept(HttpdClientHandler, NULL);
>
> This function is blocking and starts only one thread which is listening
> for incomming requests. I now observed, that when accessing a little
> website with Firefox, not all requests seem to be answered.
You may start a number of threads like this:
THREAD(HttpDaemon, arg)
{
for (;;) {
StreamClientAccept(HttpdClientHandler, NULL);
}
}
Of course you can also create threads dynamically on new connections and exit them when the connection has been closed.
> There is a list of default media types. Some of them use an empty
> sub-type like "css" for example.
>
> The media type for CSS should be text/css
>
> Shouldn't the sub-type be "css" in this case?
Good question. :-) When looking to the list mt_defaults in mtinit.c I assume that my initial idea was to save memory for the literal string, if the subtype is the same as the file extension. However, I'm currently not able to figure out where this case is handled. Right now it looks like a bug to me.
May be
static const char mtc_css[] = "css";
#ifdef HTTP_MEDIATYPE_CSS
{ ISC_LINK_INITIAL(MEDIA_TYPE_ENTRY), mtc_text, mtc_css, MTFLAG_INITIAL, MediaTypeHandlerText, mtc_css },
#endif
will do the trick.
Or should we leave this to the optimizer? Most compilers optimize away duplicate string literals.
Regards,
Harald
More information about the En-Nut-Discussion
mailing list