2011-08-12 24 views
0

什麼是android Post方法的最大尺寸?當我收到來自服務器的響應時,部分消息丟失。我認爲它可能已達到post方法的最大大小。 如果post方法沒有限制,是否需要更改我的服務器規範?什麼是Android Post方法的最大尺寸android

+0

它似乎是基於瀏覽器,並基於服務器的配置。我不認爲(理論上)有一個限制。 – Randroid

回答

0

理論上沒有限制。 POST響應大小限於Java VM堆大小which is device independent。這可能比您的帖子回覆消耗的要多。

如何驗證您的部分響應是否缺失?如果您使用LogCat打印出來或者在調試模式下查看它,那麼您只能看到以三個點結尾的消息的開頭(所有消息都在那裏,而不是隻顯示給您)。

1

我有同樣的問題,我使用HttpPost和從服務器得到的響應,但一部分數據由於其非常大的規模而錯過了。這就是爲什麼我使用其他方式:HttpURLConnection與OuputStream發送請求到服務器和BufferedReader/InputStream獲取響應。

HttpURLConnection my_httpConnection = (HttpURLConnection) new URL("https://integrator-ut.vegaconnection.com/Authentication.svc?wsdl").openConnection(); 
    my_httpConnection.setRequestMethod("POST"); 
    my_httpConnection.setDoInput(true); 
    my_httpConnection.setDoOutput(true); 
    my_httpConnection.setRequestProperty("Content-type", "text/xml; charset=utf-8"); 



    OutputStream my_outPutStream = this.my_httpConnection.getOutputStream(); 
    Writer my_writer = new OutputStreamWriter(my_outPutStream); 
    my_writer.write(YOUR_REQUEST); //YOUR_REQUEST is a String 
    my_writer.flush(); 
    my_writer.close();   

    BufferedReader my_bufferReader = new BufferedReader(new InputStreamReader(this.my_httpConnection.getInputStream())); 
    char[] buffer = new char[10000]; 
    int nbCharRead=0; 
    try 
    { 
     while((nbCharRead = my_bufferReader.read(buffer, 0, 10000)) != -1) 
     { 
      /* Your treatement : saving on a file/arraylist/etc 

     } 
    }