Skip to content

[BUG] register_resource won't accept the same resource string for both family=true and family=false. #305

Closed

Description

@bcsgh

Prerequisites

Description

The following code will fail

void RegisterResources(httpserver::webserver *ws) {
  CHECK(ws->register_resource("/", root_page, false));
  CHECK(ws->register_resource("/", fallback, true));  // This fails
}

In general, only the first register resource for any given path will be accepted, even if the resources would match differently.

The intent in this specific case is to have the second handler as a fallback that deals with anything not otherwise handled (e.g. return a 401 if not logged in or 404 otherwise). At the same time, there is still a need to handle the root URL which incidentally uses the same resource string.

I know it's possible to handle this outside the libhttpserver, but then what's the point in having register_resource at all?

Steps to Reproduce

Build a server with the above code.

Expected behavior: [What you expect to happen]

Family and non-family resources with the same path should not conflict.

Actual behavior: [What actually happens]

Regardless of family/non-family, resources with the same path conflict.

Reproduces how often: [What percentage of the time does it reproduce?]

100%

Versions

  • All OS
  • current libhttpserver master branch
  • libmicrohttpd version (most likely irrelevant)

Activity

  1. added
    bugConfirmed bugs or reports that are very likely to be bugs.
    on Apr 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugConfirmed bugs or reports that are very likely to be bugs.

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions