ikenator ikenator - 4 months ago 25
Node.js Question

Node.js request GET a VAST tag

I am trying to make a GET request to a certain url that returns a VAST tag. When I curl the url,

curl -v 'http://a.host.for.vasttag.com/foo/ad.jsp?fooid=someidhere'
I receive normal html like this:

<script type="text/javascript" src="foobar.js"></script><script type="text/javascript">var FOO_customization = {"account":"foo1","playerid":"foo1232","inapp":"true","domain":"foodomain.com"}</script><script type="text/javascript" id="exampleBanner" src="http://this.is.net/banner/LATEST/inbanner.min.js"></script>

I would like to receive the same response in my node.app, but I only receive this:

<?xml version="1.0" encoding="utf-8"?> <VAST version="3.0"></VAST>

What did I do wrong? Here is my code:

var http = require('http')

var options = {
method : 'GET',
host: 'a.host.for.vasttag.com',
port: 80,
path: '/foo/ad.jsp?fooid=someidhere',
headers: {'Content-Type': 'text/html'},

http.get(options, function(res) {
console.log("Got response: " + res.statusCode)
res.on("data", function(chunk) {
}).on('error', function(e) {
console.log("Got error: " + e.message)


It may seem a bit weird, but some VAST engines won't give a response unless you specify a User-Agent

This is what my VAST server guys told me.

And User-Agent is a mandatory header for protocol in order to obtain a VAST response (it’s used in ad targeting). That is why without User-Agent you got an empty response.

Try adding

var options = {
    method: 'GET',
    host: 'a.host.for.vasttag.com',
    port: 80,
    path: '/foo/ad.jsp?fooid=someidhere',
    headers: {
      'Content-Type': 'text/html',
      'User-Agent': 'Fiddler' //here

P.S: I used Fiddler cos it was the shortest and it worked.