I have searched the entire net and read all the mail archives I can find to understand http servers and their use of Status Code 100. I see how the http-server uses it, and how theoretically the client is supposed to implement it, however, I cannot get my HttpMethod to retrieve the final Status 200.
I found these previous posting which make mention of patches to the HttpClient, but I can't tell whether they are directly related to my problem or not, or whether they are included in the current version of Http-Client Commons. http://www.mail-archive.com/[email protected]/msg03514.html http://www.mail-archive.com/commons- [EMAIL PROTECTED]/msg03146/HttpMethodBase.diff I figure that I must not understand how to completely close a POST, or maybe I need to override the processStatusLine methods, but I have no idea what I would be doing in there as I haven't had success in reading anything different from them. I would greatly appreciate some pointers for how to pass through the Status 100 code and finish retrieving the response from the POST that comes with the Status 200 response body that I'm looking for. Below is the inner class I'm using for the executeMethod argument. It works flawlessly for GET, and even for uploading files via POST, I just can't get past the Status 100 code to get the response body properly after the file has uploaded correctly. Thank you for any light you can shed on this. *************************************** HttpBaseMethod inner-class *************************************** /** * This inner-class is used to perform method calls on the httpSession that is created */ private class ServerMethod extends HttpMethodBase { private String name = "GET"; // default is GET private File postFile = null; public ServerMethod(String path, String query) throws Exception { setPath(path); setQueryString(query); } public ServerMethod(String path) throws Exception { setPath(path); } public InputStream getBody() throws Exception { return getResponseBodyAsStream(); } public String getName() { return name; } public void setName(String name) { this.name = name; } public void postFile(File filename) throws Exception { this.postFile = filename; // not sure if this header is necessary, but I'll put it in for good measure // this was part of an endless testing of headers to make it work the first time DataInputStream in = new DataInputStream(new FileInputStream(postFile)); addRequestHeader(new Header("Content-Length", String.valueOf(in.available()))); in.close(); } public boolean writeRequestBody(HttpState state, HttpConnection httpConn) { try { if(postFile != null && getName().equals("POST")) { if(debug) {System.out.println("Uploading File...");} DataOutputStream outStream = new DataOutputStream(httpConn.getRequestOutputStream()); DataInputStream in = new DataInputStream(new FileInputStream(postFile)); if(debug) {System.out.println("Available: " + in.available());} while(in.available() > 0) { outStream.write(in.readByte()); } in.close(); // httpConn.writeLine(); outStream.close(); } else { // by default if we're not uploading anything if(debug) {System.out.println("Writing Normal Request Body");} super.writeRequestBody(state, httpConn); } } catch(IOException e) { HandleExceptions.handle(e); return false; } catch(HttpException e2) { HandleExceptions.handle(e2); return false; } return true; } /** * This is used for debugging more than anything */ public void display() throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader(getBody())); String temp = ""; while((temp = in.readLine()) != null) { System.out.println(temp); } in.close(); } public String getDisplayString() throws Exception { return getResponseBodyAsString(); } }; --------------------------------------------------------- Ben Christensen Novisum Development Inc. [EMAIL PROTECTED] 780-909-4707 -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
