I am able to send a request to browsermob using curl like so:
curl -X PUT -d "pageRef=car" localhost:9000/proxy/8081/har/pageRef
. However, I would like to do this inside nodejs using the request module. What is the equivalent command using the request module? I assume it is something like request.put(url, data, callback)
but when I try request.put('localhost:9000/proxy/8081/har/pageRef', {form: { pageRef: encodeURI(browser.platform) + encodeURI(browser.browserName) + encodeURI(browser.version) }})
, I get
Error: Invalid protocol
at Request.self._buildRequest (/Users/dragonite/Pixel/node_modules/request/request.js:336:53)
at Request.init (/Users/dragonite/Pixel/node_modules/request/request.js:503:10)
at new Request (/Users/dragonite/Pixel/node_modules/request/request.js:97:8)
at request (/Users/dragonite/Pixel/node_modules/request/index.js:50:11)
at Function.request.put (/Users/dragonite/Pixel/node_modules/request/index.js:121:27)
at repl:1:10
at REPLServer.self.eval (repl.js:110:21)
at Interface.<anonymous> (repl.js:239:12)
at Interface.emit (events.js:95:17)
at Interface._onLine (readline.js:203:10)
It looks like you are just missing the protocol in front of the url like:
request.put('http://localhost:9000/proxy/8081/har/pageRef', {form: { pageRef: encodeURI(browser.platform) + encodeURI(browser.browserName) + encodeURI(browser.version) }})