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.
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 bothrequest.protocol
andrequest.hostname
are not present in the mockrequest
instance.How to reproduce?
Parsing the given URL inside the
HttpRequestImpl
setter for theurl
field and settingprotocol
andhostname
fields from there might help solve this issue.