"Richard Sayre" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Thank you everyone for all the help I am getting. I have been doing > some debugging and it seems that Tomcat is ok. As I stated earlier > there is only one piece of code not working, I have other code that is > successfully getting data from the server. > > Here is what I found out using Ethereal: > > 1) I am always using POST as my method for getting XML data from the > web (setting it in the C# object). But for some reason, unless I > write data to the request, it uses the GET method (perhaps if the > object doesn't write data it doesn't see a need to post??). > 2) The other code that I have that uses POST and writes data to the > request before receiving a response is receiving 100 Continue from > Tomcat before it accepted the data from the Pocket PC.
This is normal. The client asked Tomcat to tell it when it is ready to read the data (and Tomcat obliges by sending '100 Continue'). Only then will Tomcat attempt to read the body. > 3) After Tomcat received the data it sent '200 OK' back to the Pocket > PC and then send the XML data. > 4) My code that isn't working was not receiving 100 or 200 but was > still sending the data to the server anyway. > And here is the problem. If Tomcat doesn't send a '100 Continue', then it isn't expecting to see the post body. It is expecting that the next thing it reads is the request line for the next request. What it actually sees is the first part of the previous request's post body. Since this doesn't look like a valid request line, it replies with a 505. This is a bug in the client. Since it explicitly asked Tomcat to tell it when it is ready to read the body (by sending a "Expect: 100-Continue" request header), it is supposed to wait for Tomcat to respond before sending the body. This is so that, if Tomcat decides that it doesn't want the body (e.g. it is sending back a '401 Unauthorized'), then the client can save bandwidth by not sending the body. A simple Google of '100-continue .net' will give you a bunch of pages about how .net has problems in this area. > I checked the working code vs. the broken code a noticed that the > working code has 'keepAlive' set to false in my Request object. I set > this in my broken code and it worked. I'm not sure why, this code is > over 5 years old and it the first time it has been changed in a while. > I'm not sure why Tomcat 6 didn't like the way the object behaved with > keep alive set to true but as long as it works I'm happy. > If keepAlive=false, then the client closes the old connection and opens a new one. The old post body disappears into the black hole of the closed connection, and the new request on the new connection succeeds. > Thanks again everyone for your help. > > > Rich > > On Dec 5, 2007 4:04 PM, Filip Hanik - Dev Lists <[EMAIL PROTECTED]> > wrote: >> that looks like a valid request, there most be something else in the >> data sent over that breaks it >> >> there is only one place where tomcat checks for this, its in the >> Http11Processor >> you should be able to turn on the debug to get the actual data that >> tomcat is trying to parse >> >> put >> org.apache.coyote.http11.level = FINE >> in logging to properties, and Tomcat will print out the data it is >> trying to parse (see below) >> >> MessageBytes protocolMB = request.protocol(); >> if (protocolMB.equals(Constants.HTTP_11)) { >> http11 = true; >> protocolMB.setString(Constants.HTTP_11); >> } else if (protocolMB.equals(Constants.HTTP_10)) { >> http11 = false; >> keepAlive = false; >> protocolMB.setString(Constants.HTTP_10); >> } else if (protocolMB.equals("")) { >> // HTTP/0.9 >> http09 = true; >> http11 = false; >> keepAlive = false; >> } else { >> // Unsupported protocol >> http11 = false; >> error = true; >> // Send 505; Unsupported HTTP version >> if (log.isDebugEnabled()) { >> >> log.debug(sm.getString("http11processor.request.prepare")+ >> " Unsupported HTTP version >> \""+protocolMB+"\""); >> } >> response.setStatus(505); >> >> } >> >> >> Richard Sayre wrote: >> > Here is the exact String exported from the packet: >> > >> > POST /test/sync/upload.jsp?username=test1 HTTP/1.1 >> > Content-Type: text/xml >> > Content-Length: 4005 >> > Connection: Keep-Alive >> > Expect: 100-continue >> > Host: 192.168.1.116 >> > >> > On Dec 5, 2007 2:29 PM, Richard Sayre <[EMAIL PROTECTED]> wrote: >> > >> >> The spacing seems to be ok. I request several pages using the C# >> >> object. The only time I get that error is when I write some data to >> >> the request before I get the response. Here is the request String: >> >> >> >> >> >> POST /test/sync/upload.jsp?username=test1 HTTP/1.1 >> >> >> >> >> >> On Dec 5, 2007 2:17 PM, Dwebb <[EMAIL PROTECTED]> wrote: >> >> >> >>> Hi, >> >>> >> >>> You might want to check the Request line in a tcp capture. We have >> >>> run >> >>> into a problem recently with the new tomcat bundles that do very >> >>> strict >> >>> checking of the request line. >> >>> >> >>> It has to be formatted METHOD SPACE REQUEST_URI SPACE VERSION (ie >> >>> POST /test HTTP/1.1). if there are more than one space between the >> >>> elements you will get a 505 error. >> >>> >> >>> see: http://issues.apache.org/bugzilla/show_bug.cgi?id=42750 >> >>> >> >>> They seem to ignore Appendix B of RFC1945 >> >>> (http://tools.ietf.org/html/rfc1945#page-55) >> >>> >> >>> Cheers >> >>> >> >>> Danny >> >>> >> >>> >> >>> >> >>> On Wed, 2007-12-05 at 14:02 -0330, Richard Sayre wrote: >> >>> >> >>>> I have a C Sharp Pocket PC application that is hitting a Tomcat web >> >>>> server and getting some data from that server. With Tomcat 4.1 this >> >>>> application is working fine, but since I upgraded to Tomcat 6 it >> >>>> stopped working. >> >>>> >> >>>> Most of the application works with Tomcat 6. When It does work here >> >>>> is the scenario: >> >>>> >> >>>> >> >>>> 1. My C# app sends a request to /webapp/getCustomers.jsp?custId=1 >> >>>> through "POST" >> >>>> 2. The jsp servlet gets some XML from the model and puts it into a >> >>>> String and prints it using the output stream >> >>>> 3. the C# App receives the data ok through a response object >> >>>> >> >>>> >> >>>> When it doesn't work the following occurs: >> >>>> >> >>>> >> >>>> 1. Pocket Pc requests a page through POST and opens a stream >> >>>> and >> >>>> writes some data to the stream (Some xml data) >> >>>> 2. The pocket pc app tries to obtain a Response object from >> >>>> the request >> >>>> 3. On the line of code that tries to obtain a response I get a >> >>>> server error >> >>>> >> >>>> >> >>>> >> >>>> HTTP/1.1 505 >> >>>> >> >>>> HTTP Version Not Supported..Server: Apache-Coyote/1.1..Date: Tue, 04 >> >>>> Dec 200713:08:21 GMT..Connection: close >> >>>> >> >>>> Which is weird since my connector is as follows: >> >>>> >> >>>> <Connector URIEncoding="utf-8" connectionTimeout="20000" port="8084" >> >>>> protocol="HTTP/1.1" redirectPort="8443"/> >> >>>> >> >>>> I am using Tomcat 6.0.14 which came bundled with Netbeans 6. >> >>>> >> >>>> Thank you, >> >>>> >> >>>> Rich >> >>>> >> >>>> --------------------------------------------------------------------- >> >>>> To start a new topic, e-mail: users@tomcat.apache.org >> >>>> To unsubscribe, e-mail: [EMAIL PROTECTED] >> >>>> For additional commands, e-mail: [EMAIL PROTECTED] >> >>>> >> >>>> >> >>> --------------------------------------------------------------------- >> >>> To start a new topic, e-mail: users@tomcat.apache.org >> >>> To unsubscribe, e-mail: [EMAIL PROTECTED] >> >>> For additional commands, e-mail: [EMAIL PROTECTED] >> >>> >> >>> >> >>> >> > >> > --------------------------------------------------------------------- >> > To start a new topic, e-mail: users@tomcat.apache.org >> > To unsubscribe, e-mail: [EMAIL PROTECTED] >> > For additional commands, e-mail: [EMAIL PROTECTED] >> > >> > >> > >> > >> >> >> --------------------------------------------------------------------- >> To start a new topic, e-mail: users@tomcat.apache.org >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> > > --------------------------------------------------------------------- > To start a new topic, e-mail: users@tomcat.apache.org > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]