retsef
unread,Jan 9, 2011, 6:44:25 PM1/9/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Webduino
Hi,
i have started (2011-jan-09) working with WebServer as a swap for my
own solution for Arduino server. Unfortunatelly i have found a bug in
dispatchCommand already at the beginning of work. It works as follows.
When dispatchCommand is called it received pointer to buffer moved
with length of PREFIX used - by default "/". In dispatch command there
is code however that checks and works only if at char [0] there is
"/". This of course does not work when page is located at "/" with the
same prefix.
I know it can be corrected with setting empty PREFIX for constructor
of webserver but it would be also correct if dispatch command would
look like following:
===========================================
bool WebServer::dispatchCommand(ConnectionType requestType, char
*verb,
bool tail_complete)
{
if ((verb[0] == 0) || ((verb[0] == '/') && (verb[1] == 0)))
{
m_defaultCmd(*this, requestType, verb, tail_complete);
return true;
}
char i;
char *qm_loc;
int verb_len;
int qm_offset;
// We now know that the URL contains at least one character. And,
// if the first character is a slash, there's more after it.
if (verb[0] == '/')
{
// Skip over the leading "/", because it makes the code more
// efficient and easier to understand.
verb++;
}
// Look for a "?" separating the filename part of the URL from the
// parameters. If it's not there, compare to the whole URL.
qm_loc = strchr(verb, '?');
verb_len = (qm_loc == NULL) ? strlen(verb) : (qm_loc - verb);
qm_offset = (qm_loc == NULL) ? 0 : 1;
for (i = 0; i < m_cmdCount; ++i)
{
if ((verb_len == strlen(m_commands[i].verb))
&& (strncmp(verb, m_commands[i].verb, verb_len) == 0))
{
// Skip over the "verb" part of the URL (and the question
// mark, if present) when passing it to the "action" routine
m_commands[i].cmd(*this, requestType,
verb + verb_len + qm_offset,
tail_complete);
return true;
}
}
return false;
}
===========================================
Regards
Sebastian Tyl