title: luaSocket HTTP requests always respond with a redirect (301 or 302)
body: <p>I use LuaForWindows (latest version) and I have read <a href="https://stackoverflow.com/questions/10360632">this</a> and <a href="https://stackoverflow.com/questions/10306489">this</a> answer and everything i could find in the <a href="http://lua-users.org/lists/lua-l/" rel="nofollow noreferrer">mailinglist</a> of lua-users.org. What ever I try (most) sites only respond with either 301 or 302. I have created an example batch script which downloads (some) of the OpenGL 2.1 Reference from their man pages.</p>
  
  <pre><code>@ECHO OFF
  
  FOR /F "SKIP=5" %%# IN ( %~fs0 ) DO lua -l socket.http -e "print(socket.http.request('https://www.opengl.org/sdk/docs/man2/xhtml/%%#.xml'))"
  GOTO:EOF
  
  glAccum
  glActiveTexture
  glAlphaFunc
  glAreTexturesResident
  glArrayElement
  glAttachShader
  glBegin
  glBeginQuery
  glBindAttribLocation
  glBindBuffer
  </code></pre>
  
  <p>the most important part is this:</p>
  
  <pre><code>print(require('socket.http').request('https://www.opengl.org/sdk/docs/man2/xhtml/glAccum.xml')) -- added glAccum so you can run it
  </code></pre>
  
  <p>This ALWAYS returns a 301. This also happens to me when downloading from other random pages. (I dont note them so I cant give a list, but i happened to find out some of them use cloudflare.)</p>
  
  <p>If i write an equivalent downloader in Java using <a href="https://docs.oracle.com/javase/7/docs/api/java/net/URL.html" rel="nofollow noreferrer">URL</a> and <a href="https://docs.oracle.com/javase/7/docs/api/java/net/URL.html#openConnection%28%29" rel="nofollow noreferrer">openConnection()</a> it wont redirect.</p>
  
  <p>I already tried folowing the redirect manually (setting refferer and stuff) and using <a href="https://stackoverflow.com/questions/10306489#10308671">the 'generic' way</a>. As most of the tips stated in other answers.</p>