Skip to content

[BUG] URL's that exactly match a registried regex pattern dispatch to that registered resource #308

Open
@bcsgh

Description

@bcsgh

Prerequisites

Description

This test here is in error because that map is populated with the URL including the regexp pattern.

This results in a url that includes the same text as the regex pattern matching, even if that text isn't matched by the regex.

Steps to Reproduce

Add the following to test/integ/basic.cpp (2ea297f):

LT_BEGIN_AUTO_TEST(basic_suite, regex_url_exact_match)
    ok_resource resource;
    ws->register_resource("/foo/{v|[a-z]}/bar", &resource);
    curl_global_init(CURL_GLOBAL_ALL);

    string s;
    CURL *curl = curl_easy_init();
    CURLcode res;

    // Exact string match for the registered pattern 
    curl_easy_setopt(curl, CURLOPT_URL, "localhost:8080/foo/{v|[a-z]}/bar/");

    curl_easy_setopt(curl, CURLOPT_HTTPGET, 1L);
    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writefunc);
    curl_easy_setopt(curl, CURLOPT_WRITEDATA, &s);
    res = curl_easy_perform(curl);
    LT_ASSERT_EQ(res, 0);

    int64_t http_code = 0;
    curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE , &http_code);
    LT_ASSERT_EQ(http_code, 404);    /// <<<<<<<<<<<<< This fails: 200!=404
    curl_easy_cleanup(curl);
LT_END_AUTO_TEST(regex_url_exact_match)

Expected behavior: HTTP 404 (assuming the RE pattern doesn't match itself).

Actual behavior: HTTP 200

Reproduces how often: 100%

Versions

Current master branch

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