我的問題是getInputStream()
掛起時,我試圖打開一個流發佈到服務器後。用python編寫的服務器給出了一個錯誤消息,導致我相信它無法正確解析我的查詢字符串。請幫我診斷這個問題。getInputStream()掛在POST請求
我張貼與下面的代碼的Web服務器:
String boundarySolo = "--158211729626281";
String boundary = boundarySolo + "\r\n";
String contentHeader = "Content-Disposition: form-data; name=\"";
URL requestUrl;
URLConnection connection;
String queryString = new String();
try{
requestUrl = new URL(config.getServerUrl());
connection = requestUrl.openConnection();
connection.setReadTimeout(1000);
connection.setDoOutput(true);
connection.setDoInput(true);
connection.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundarySolo);
。 。 。
outStream = new DataOutputStream(connection.getOutputStream());
System.out.println("Writing bytes...");
outStream.writeUTF(queryString);
System.out.println("Bytes written");
outStream.flush();
System.out.println("Buffer flushed.");
outStream.close();
System.out.println("Stream closed.");
try{
inStream = new DataInputStream(connection.getInputStream());
String buffer;
System.out.println("Entering the loop.");
while((buffer = inStream.readLine())!= null)
System.out.println(buffer);
System.out.println("Leaving the loop.");
}
catch (SocketTimeoutException e) {
System.out.println("Socket timed out.");
}
查詢字符串由這個(與\r\n
在每一行的末尾):
--158211729626281
Content-Disposition: form-data; name="view"
a
--158211729626281
Content-Disposition: form-data; name="termdb"
Saccharomyces_cerevisiae.etd
--158211729626281
Content-Disposition: form-data; name="raw_weights"
blank
--158211729626281
Content-Disposition: form-data; name="MAX_FILE_SIZE"
256
--158211729626281
Content-Disposition: form-data; name="cutoff_Evalue"
0.01
--158211729626281
Content-Disposition: form-data; name="min_term_size"
2
--158211729626281
Content-Disposition: form-data; name="effective_tdb_size"
0
--158211729626281
Content-Disposition: form-data; name="stats"
wsum
--158211729626281
Content-Disposition: form-data; name="transform_weights"
null
--158211729626281
Content-Disposition: form-data; name="cutoff_type"
none
--158211729626281
Content-Disposition: form-data; name="output"
tab
--158211729626281--
什麼錯誤訊息您在服務器獲取呢?然後,您可能希望將其重新構建爲Python目標問題。 – BalusC