title: HTTPotion.get with "Referer" in header
body: <p>This is the first time I'm working with <code>Elixir</code>, so I'm having some issues with my first app. I'm trying to implement the equivalent of the following <code>curl</code>-request in elixir with the help of <code>HTTPotion</code>:</p>
  
  <pre class="lang-sh prettyprint-override"><code>$ curl -s -X GET https://secure.us.playstation.com/playstation/psn/profile/public/userData?onlineId=eagon1337 --referer https://secure.us.playstation.com/logged-in/trophies/public-trophies/ | python -mjson.tool
  {
      "avatarUrl": "//static-resource.np.community.playstation.net/avatar_m/3RD/UP40731301009_65ED8105B0C68DC79ABC_M.png",
      "curLevel": "3",
      "handle": "eagon1337",
      "isPlusUser": "1",
      "progress": "15",
      "totalLevel": "",
      "trophies": {
          "bronze": "44",
          "gold": "0",
          "platinum": "0",
          "silver": "1"
      }
  }
  </code></pre>
  
  <p>Which sends the following Request-Header:</p>
  
  <pre><code>&gt; GET /playstation/psn/profile/public/userData?onlineId=eagon1337 HTTP/1.1
  &gt; User-Agent: curl/7.30.0
  &gt; Host: secure.us.playstation.com
  &gt; Accept: */*
  &gt; Referer: https://secure.us.playstation.com/logged-in/trophies/public-trophies/
  </code></pre>
  
  <p>I came up with the following Elixir code:</p>
  
  <pre><code>defmodule PS4 do
      def helloWorld do
  
          name = "eagon1337"
          url = "https://secure.us.playstation.com/playstation/psn/profile/public/userData?onlineId=" &lt;&gt; name
          headers = [{"Accept", "*/*"},
                     {"Host", "secure.us.playstation.com"},
                     {"Referer", "https://secure.us.playstation.com/logged-in/trophies/public-trophies/"},
                     {"User-Agent", "curl/7.30.0"}]
  
          IO.puts "Getting " &lt;&gt; url
  
          response = HTTPotion.get url, headers: headers
  
          IO.puts response.body
  
      end
  end
  </code></pre>
  
  <p>Which results in</p>
  
  <pre><code>iex(1)&gt; PS4.helloWorld
  Getting https://secure.us.playstation.com/playstation/psn/profile/public/userData?onlineId=eagon1337
  ** (HTTPotion.HTTPError) req_timedout
      (httpotion) lib/httpotion.ex:209: HTTPotion.handle_response/1
            (ps4) lib/ps4.ex:14: PS4.helloWorld/0
  </code></pre>
  
  <p>Running the whole request against <a href="http://httpbin.org/get" rel="nofollow">http://httpbin.org/get</a> results in a pretty smooth header (with additional removing of the "host"-header):</p>
  
  <pre><code>iex(1)&gt; PS4.helloWorld
  Getting httpbin.org/get
  {
    "args": {}, 
    "headers": {
      "Accept": "*/*", 
      "Content-Length": "0", 
      "Host": "httpbin.org", 
      "Referer": "https://secure.us.playstation.com/logged-in/trophies/public-trophies/", 
      "User-Agent": "curl/7.30.0"
    }, 
    "origin": "92.77.68.151", 
    "url": "http://httpbin.org/get"
  }
  
  :ok
  </code></pre>
  
  <p>Obviously the requested URL expects a specific Referer. But why is it working with curl, but not via my Elixir approach? What am I missing?</p>