Skip to content

Conversation

rolfmorel
Copy link
Contributor

which adds support for resolving the URL in the function itself, when it doesn't match default or specified paths.

Modified Command prototype, UrlPathCommand, now returns the extra parameter char **url_path. url_path contains pointers to the separate parts of the URL path.

Example:

void urlPageCmd(WebServer &server, WebServer::ConnectionType type,
                char **url_path, char *url_tail, bool tail_complete) {
  int len_url_path = 0, n = 0;
  while (*(url_path + n++)) ++len_url_path;

  if (len_url_path)
  {
    if (strcmp(url_path[0], "400") == 0) 
    {
      server.httpFail();
      if (!tail_complete) {
        server.print("buffer to small for url\n");
      }
      return;
    }
  }

  server.httpSuccess();

  server.print("url_parts=");
  server.print(len_url_path);
  server.print(CRLF);

  for (uint8_t i = 0; i < len_url_path; i++)
  {
    server.print("url_part");
    server.print(i);
    server.print("=");

    char *p = url_path[i];

    while (*p != 0) server.print(*p++);

    server.print(CRLF);
  }
}

webserver.setUrlPathCommand(&urlPageCmd);

…L in the function itself, when it doesn't match default or specified paths.

Modified Command prototype, UrlPathCommand, now returns the extra parameter char **url_path. url_path contains pointers to the separate parts of the URL path.
unwiredben added a commit that referenced this pull request Dec 9, 2012
Add setUrlPathCommand method, ...
@unwiredben unwiredben merged commit 0e9cd1d into sirleech:master Dec 9, 2012
@unwiredben
Copy link
Collaborator

merged

@Aibwolf
Copy link

Aibwolf commented Aug 19, 2013

In the official download version for WebServer.h (sirleech/Webduino) there is the "setUrlPathCommand" still missing. This is very confusing because the sketch in the resource-link to "A Wedbuino based file server" does not work without the "setUrlPathCommand". Both (different) sources have the same version number 1.7.

@unwiredben
Copy link
Collaborator

Which resource link?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants