J2ME HttpConnection getResponseCode()ブロックを待って回答からなるサーバNokia N97

StackOverflow https://stackoverflow.com/questions/1872617

質問

私はアップロードファイルからノキアN97電話サーバーも動作がファイルアップロードしていただきたいと思い応答からサーバーです。問題は私の回答のみだったが、半分します。だからこそのコードブロックhttpConnection.getResponseCode()待ちに応じます。私は試験を実施し、ソニーエリクソンとい応答速いていると思うのであるNokia N97問題です。(なサーバーの問題で動作するその他の携帯電話)

は誰でも知ってなぜこのようなことが起きにのみノキア?

こちらはコードスニペット:

公uploadFile(){

       httpConn = (HttpsConnection) Connector.open(url, Connector.READ_WRITE);
        ...
       //set httpConn parameters and request method 
       ...

       writeParametersAndFileName(os, "text/plain");


       **writeFileToStream(os);** 

       os.write("\r\n".getBytes());
       os.write("--".getBytes());

       os.write(boundary.getBytes());

       os.write("--".getBytes());
       os.write("\r\n".getBytes());

        *//here code blocks on Nokia N97. Same thing happens if I use os.flush() after
        // I send chunks of the file*
         .....
        codeResp = httpConn.getResponseCode();
        // check condition
        checkResponseHeader();

}

公開 writeFileToStream() {

        InputStream is = null;
        FileConnection c = null;
        try
        {
           c = (FileConnection) Connector.open("file:///"+ sourcePath, Connector.READ);

           if(c.exists()) {
               is = c.openInputStream();

               long fs = c.fileSize();
               while (total < fs) {
                    byte[] data = new byte[512];
                    int readAmount = is.read(data,0,512);                       
                    total += readAmount;
                    os.write(data, 0, readAmount);


            }

            //os.flush();
        }
        catch (IOException ex) {
           //               
        }
        finally
        {
           //close connection

        }

}

役に立ちましたか?

解決

だけをお考えの方にはファイルをアップしました。

お電話でgetResponseCode()の第一の原因となるのHttpConnection実際にはサーバー通信を行います。

な戻りまで遊びのファイルの、と思われるようになります。

これは完全に有効な行動によるHttpConnection仕様JSR-118:

" 以下の手法の原因への移行に接続される場合には、接続には設定の状態です。

* openInputStream
* openDataInputStream
* getLength
* getType
* getEncoding
* getHeaderField
* getResponseCode
* getResponseMessage
* getHeaderFieldInt
* getHeaderFieldDate
* getExpiration
* getDate
* getLastModified
* getHeaderField
* getHeaderFieldKey 

"

期待しているその他の携帯電話またこれ以上のN97、フラッシュする必要はOutputStream、そのためサーバへの接続前には仕様通りにしてください。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top