title: HTTP/1.1 406 Not Acceptable with Delphi and PHP
body: <p>I have a simples <code>IdHTTP.Get()</code> to get a file contents, and <code>IdHTTP.Post()</code> to send a file via param, that I used with Delphi 2006. It worked like very well and fast. The first version was via IdFTP and it was very slow.</p>
  
  <p>Now I copied that code to an Android App with XE8 and I get the error</p>
  
  <blockquote>
    <p>http1.1-406-not-acceptable </p>
  </blockquote>
  
  <p>when I try to upload the file. The download via Get() is ok. It seems that the problem is with the response of the post, but I think it should at least finish sending the file, but does not.</p>
  
  <p>IdHTTP.pas where the program breaks when I run it in Win32:</p>
  
  <pre><code>  case FHTTPProto.ProcessResponse(AIgnoreReplies) of
      wnAuthRequest:
        begin
          Request.URL := AURL;
        end;
      wnReadAndGo:
        begin
          ReadResult(Request, Response);
          if Assigned(AResponseContent) then begin
            AResponseContent.Position := LResponseLocation;
            AResponseContent.Size := LResponseLocation;
          end;
          FAuthRetries := 0;
          FAuthProxyRetries := 0;
        end;
      wnGoToURL:
        begin
          if Assigned(AResponseContent) then begin
            AResponseContent.Position := LResponseLocation;
            AResponseContent.Size := LResponseLocation;
          end;
          FAuthRetries := 0;
          FAuthProxyRetries := 0;
        end;
      wnJustExit: 
        begin
          Break;
        end;
      wnDontKnow:
        begin
          raise EIdException.Create(RSHTTPNotAcceptable);
        end;
    end;
  until False;
  </code></pre>
  
  <p>I think, by reading your responses to other users questions about Indy, is that something is wrong with Encoding. But I confess I am very noob at this (did not needed to study encoding types until now) and do not understand the Delphi changes in this matter. Please help me! I don't want to use FTP again.</p>
  
  <p>My Code inside of the try-except in the thread (i suppressed some URL part):</p>
  
  <pre><code>  Params := TIdMultipartFormDataStream.Create;
    Params.AddFile('dc',FilesPath+FileName));
    webRequest := TIdHttp.Create;
    webRequest.ConnectTimeout := 0;
    webRequest.ReadTimeout := 0;
    SaveCheck := webRequest.Post('http://alcantara.net.br/ristretto/?ac=ul', Params);
    ShowMessage(SaveCheck);
    Params.Free;
    aStream.Free;
    webRequest.Free;
  </code></pre>
  
  <p>Inside my hostgator server with download and upload code, it works when I test from the browser:</p>
  
  <pre class="lang-php prettyprint-override"><code>if ((isset($_REQUEST['ac'])) &amp;&amp; ($_REQUEST['ac']=='dl'))
  {
      $LoginNX = @$_REQUEST['ln'];
      $LoginKX = @$_REQUEST['lk'];
      $DocumentNX = @$_REQUEST['dn'];
      $DocumentKX = @$_REQUEST['dk'];
      $FileName = md5($LoginNX.$LoginKX.$DocumentNX.$DocumentKX);
      if (file_exists($FileName))
      {
          echo file_get_contents($FileName);
      }
      else
      {
          echo '@newdoc';
      }
  }
  
  if ((isset($_REQUEST['ac'])) &amp;&amp; ($_REQUEST['ac']=='ul'))
  {
      $LoginNX = @$_REQUEST['ln'];
      $LoginKX = @$_REQUEST['lk'];
      $DocumentNX = @$_REQUEST['dn'];
      $DocumentKX = @$_REQUEST['dk'];
      $Document = @$_REQUEST['dc'];
      $FileName = md5($LoginNX.$LoginKX.$DocumentNX.$DocumentKX);
      try
      {
          //file_put_contents($FileName, $Document);
          if (move_uploaded_file($_FILES['dc']['tmp_name'], $FileName) === false) 
          {
              echo 'Erro: arquivo inválido!';
          }
          else
          {
              echo '@finish';
          }
      }
      catch (Exception $error)
      {
          echo 'Erro :' . $error-&gt;getMessage();
      }
  }
  </code></pre>
  
  <p>The goal is to make a text editor that stores the files in cloud to avoid loss when loose cellphone or phone reset, but a plus is that it is cyphered with rca with keys not stored in the cloud. </p>