How to get the unparsed query string from a http request in Express

I can use the below to get the query string.

  var query_string = request.query;

What I need is the raw unparsed query string. How do I get that? For the below url the query string is { tt: 'gg' }, I need tt=gg&hh=jj etc....

http://127.0.0.1:8065?tt=gg

Server running at http://127.0.0.1:8065
{ tt: 'gg' }

You can use node's URL module as per this example:

require('url').parse(request.url).query

e.g.

node> require('url').parse('?tt=gg').query
'tt=gg'

Or just go straight to the url and substr after the ?

var i = request.url.indexOf('?');
var query = request.url.substr(i+1);

(which is what require('url').parse() does under the hood)

If you want it to be that "lightweight", you have to write it yourself.

var raw = "";
for( key in query_string)
  raw += key + "="+ query_string[key] "&";
if ( raw.indexOf("&") > 0) // To remove the last & since it will produce 'tt=gg&'
   raw = raw.substring(0,raw.length-1);