Stack Exchange
Indy Get response text while not handling 302
    FHTTP.HandleRedirects := False;
    try

      StrPage := FHTTP.Get('https://somesite.site');
    except
    end;

There is redirect 302 , but i need to get text from this reqest..
Response:

    (Status-Line):HTTP/1.1 302 Found
    Cache-Control:no-cache, no-store
    Content-Length:148291
    Content-Type:text/html; charset=utf-8
    Date:Sun, 21 Sep 2014 09:13:49 GMT
    Expires:-1
    Location:/di
    Pragma:no-cache

In response :
<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="/di">here</a>.</h2>
</body></html>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
...

How cant i get this text?

When HandleRedirects := False, 302 status code will cause TIdHTTP to raise an EIdHTTPProtocolException exception.
The content of the response can be accessed via the EIdHTTPProtocolException.ErrorMessage.
Example:
procedure TForm1.Button1Click(Sender: TObject);
var
  StrPage: string;
begin
  IdHttp1.HandleRedirects := False;
  try
    StrPage := IdHttp1.Get('http://www.gmail.com/');
  except
    on E: EIdHTTPProtocolException do
    begin
      if not ((E.ErrorCode = 301) or (E.ErrorCode = 302)) then raise;
      StrPage := E.ErrorMessage;
      ShowMessage(StrPage);
    end
    else
      raise;
  end;
end;

Output:
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="https://mail.google.com/mail/">here</A>.
</BODY></HTML>


In addition to @kobik's answer (which is technically accurate), there are some additional considerations.
The response body text you showed is fairly minimal, the only real piece of useful information it provides is a human-readable text message that includes an HTML link to the URL being redirected to.  If you are just interested in the URL, you can obtain it by itself from the TIdHTTP.Response.Location property, or from the TIdHTTP.OnRedirect event.  In the case of OnRedirect, you can set its Handled parameter to False to skip the actual redirection without having to set HandleRedirets to False. 
If you do not want an EIdHTTPProtocolException exception being raised on 302, you can either enable the hoNoProtocolErrorException flag in the TIdHTTP.HTTPOptions property, or else call TIdHTTP.DoRequest() directly and specify 302 in its AIgnoreReplies property. Either way, you can then check the TIdHTTP.Response.ResponseCode property after the request exits without raising an exception. However, if you disable EIdHTTPProtocolException, you lose access to the body text (TIdHTTP will read and discard it) unless you enable the hoWantProtocolErrorContent flag. Either way, you will have access to the response headers.

I didn't find anything like hoNoProtocolErrorException in HTTPOptions or anywhere else in idhttp.pas?  (v1.65 ships with XE2).

XE2 shipped with IdHTTP.pas revision 4682 (Indy 10.5.8). hoNoProtocolErrorException was added in revision 4936 (Indy 10.6.0, available in XE4), and hoWantProtocolErrorContent was added in revision 5321 (Indy 10.6.2, available in 10.1 Berlin).  If you want to use them in XE2, you will have to upgrade your Indy installation.
