title: using HTTP.request in ejs render
body: <p>example in Express I have a route that linked to my ejs middleware. <br />
  Code 1 :</p>
  
  <pre><code>app.all("/sample", function(req,res,next){
      ejs.renderFile("./sample.ejs", {req,res,next,require,module:require("module")} {}, function(e, dt){
          res.send(dt.toString());
      });
  });
  </code></pre>
  
  <p>everything fine in the first code. and in sample.ejs (second code) I want to request to some text file in Internet and return to HTML (and should use HTTP module) <br />
  Code 2:</p>
  
  <pre><code>&lt;%
      var http=require("http");
      var url=require("url");
  
      var opt = url.parse("http://website.com/thisfile.txt");
      /* it will return "Hello World!" btw */
      var dt = ""
      var hReq = http.request(opt, function(hRes){
          hRes.on("data", function(chunk){
              dt+=chunk.toString();
          });
      });
      hReq.end();
  %&gt;
  &lt;h2&gt;Here is the data is &lt;%= dt %&gt;&lt;/h2&gt;
  </code></pre>
  
  <p>and while i try to my browser. it just give me <br />
  Code 3:</p>
  
  <pre><code>&lt;h2&gt;Here is the data is &lt;/h2&gt;
  </code></pre>
  
  <p>where I want it gave me
  Code 4:</p>
  
  <pre><code>&lt;h2&gt;Here is the data is Hello World!&lt;/h2&gt;
  </code></pre>
  
  <p>How could I get that? <br />
  I just want to use HTTP Module or Net Socket Module. and I just want to edit the Code 2. Code 1 is permanently like that. <br /></p>