title: HTTP response code after redirect
body: <p>There is a redirect to server for information and once response comes from server, I want to check HTTP code to throw an exception if there is any code starting with 4XX. For that I need to know how can I get only HTTP code from header? Also here redirection to server is involved so I afraid curl will not be useful to me. </p>
  
  <p>So far I have tried <a href="https://stackoverflow.com/questions/3408049/getting-header-response-code">this solution</a> but it's very slow and creates script time out in my case. I don't want to increase script time out period and wait longer just to get an HTTP code. </p>
  
  <p>Thanks in advance for any suggestion.</p>