Skip to content

Protocol and hostname are not parsed from url for HttpRequestImpl #41

@monrax

Description

@monrax

The example that uses mock implementations in API.md results in an incomplete message that is ultimately dropped by the Resurface DB. This is due to the request_url field being skipped as both request.protocol and request.hostname are not present in the mock request instance.

How to reproduce?

// define request to log
const request = new HttpRequestImpl();
request.method = 'GET';
request.url = 'http://resurface.io';

// define response to log
const response = new HttpResponseImpl();
response.statusCode = 200;

// build JSON message
let msg = HttpMessage.build(request, response);

console.log(msg) // no request_url detail present in JSON

HttpMessage.send(logger, request, response); // this results in the request down below

//POST /message HTTP/1.1
//Content-Encoding: identity
//Content-Type: application/json; charset=UTF-8
//User-Agent: Resurface/2.2.1 (http_logger.js)
//Host: localhost:7701
//Connection: keep-alive
//Transfer-Encoding: chunked

//[["request_method","POST"],["response_code","200"],["now","1708555058014"],["host","MYPCNAME.local"]]

Parsing the given URL inside the HttpRequestImpl setter for the url field and setting protocol and hostname fields from there might help solve this issue.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions