supertest icon indicating copy to clipboard operation
supertest copied to clipboard

GET does not encode uri path in version 1.2.0

Open stelios313 opened this issue 10 years ago • 1 comments

Hello guys,

Using apicache as a cache layer on the request response level.

In my test i add in the cache an entry with key: the encoded url, and value a mock response. With version 1.1.0 this is the series of steps that are executed:

[api-cache]: path "/?filter%5BappId%5D=23%2Cglobal&filter%5BpublisherId%5D=700&filter%5Btype%5D=adx" not found in cache
[api-cache]: group detected: configurations
[api-cache]: adding cache entry for "/?filter%5BappId%5D=23%2Cglobal&filter%5BpublisherId%5D=700&filter%5Btype%5D=adx" @ 1000 milliseconds
[api-cache]: returning cached version of "/?filter%5BappId%5D=23%2Cglobal&filter%5BpublisherId%5D=700&filter%5Btype%5D=adx"
::ffff:127.0.0.1 - - [14/Jan/2015:00:00:00 +0000] "GET /configs?filter%5BappId%5D=23%2Cglobal&filter%5BpublisherId%5D=700&filter%5Btype%5D=adx HTTP/1.1" 200 102

However, with 1.2.0 it tries to access the cache entry with key the unencoded path:

GET /configs? should
[api-cache]: path "/?filter%5BappId%5D=23%2Cglobal&filter%5BpublisherId%5D=700&filter%5Btype%5D=adx" not found in cache
[api-cache]: group detected: configurations
[api-cache]: adding cache entry for "/?filter%5BappId%5D=23%2Cglobal&filter%5BpublisherId%5D=700&filter%5Btype%5D=adx" @ 1000 milliseconds
[api-cache]: path "/?filter[appId]=23,global&filter[publisherId]=700&filter[type]=adx" not found in cache

The test is a simple GET request:

request(app)
    .get('/configs?filter[appId]=23,global&filter[publisherId]=700&filter[type]=adx')
    .end(function(err, res) {
              done();
        }

Is this an intended behaviour for the version bump?

stelios313 avatar Feb 15 '16 15:02 stelios313

@stelios313 this is due to the version bump of superagent. In supertest 1.2 we upgraded from superagent 1.3 to 1.7. This change was in superagent 1.5

mikelax avatar May 26 '16 23:05 mikelax