title: Curl 400 error when using UserAgent
body: <p>Why i'm getting sometimes this error?</p>
  
  <pre><code>**Bad Request**
  
  Your browser sent a request that this server could not understand.
  Apache Server at control.digitalcoding.com Port 80
  </code></pre>
  
  <p>When </p>
  
  <pre><code>$UserAgent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11";
  </code></pre>
  
  <p>everything works fine, but not with</p>
  
  <p>Opera/7.52 (Windows NT 5.1; U) [en]
  Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1
  Mozilla/5.0 (Windows NT 6.1; rv:10.0.1) Gecko/20100101 Firefox/10.0.1</p>
  
  <p>for example. What is the problem?</p>
  
  <p><strong>HtmlReciever.php</strong></p>
  
  <pre><code>&lt;?php
  if(empty($_GET["Link"]))
  {
      echo "empty";
      die;
  }
  $LinkToFetch = urldecode($_GET["Link"]);
  $UserAgent = urldecode($_GET["UserAgent"]);
  
  
  function iscurlinstalled() 
  {
      if  (in_array  ('curl', get_loaded_extensions())) 
      {
          return true;
      }
      else
      {
          return false;
      }
  }
  
  // If curl is instaled
  if(iscurlinstalled()==true)
  {
      $ch = curl_init($LinkToFetch);
      curl_setopt($ch, CURLOPT_USERAGENT,$UserAgent); 
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
      $HtmlCode = curl_exec($ch);
      curl_close($ch);
  }
  else
  {
  
      $HtmlCode = file_get_contents($LinkToFetch);
  }
  
  echo $HtmlCode;
  ?&gt;
  </code></pre>
  
  <p>I must say that i'm running RecieverHtml.php from another .php with GET like this</p>
  
  <p><a href="http://127.0.0.1/reciever/RecieverHtml.php?Link=http%3A%2F%2Fwww.digitalcoding.com%2Ftools%2Fdetect-browser-settings.html&amp;UserAgent=Mozilla%2F5.0+%28Windows+NT+6.1%3B+rv%3A10.0.1%29+Gecko%2F20100101+Firefox%2F10.0.1%0D%0A" rel="nofollow">http://127.0.0.1/reciever/RecieverHtml.php?Link=http%3A%2F%2Fwww.digitalcoding.com%2Ftools%2Fdetect-browser-settings.html&amp;UserAgent=Mozilla%2F5.0+%28Windows+NT+6.1%3B+rv%3A10.0.1%29+Gecko%2F20100101+Firefox%2F10.0.1%0D%0A</a></p>