From: Dean M. C. B. <dmb...@fr...> - 2008-05-26 06:40:24
|
Hi Divye, Yes, you're right. I've actually been putting off re-writing this client to use the more explicit Boost.Asio interface instead of just using the Asio TCP/IP IO Stream interface. This implementation was meant to be just a stop-gap implementation, or as a proof of concept. I'll see what I can do in the next few hours about implementing this in the correct asio way using the lower level components instead of the TCP iostream interface. Thank you for this report, I hope I'll find a solution soon. -- Dean Michael Berris Software Engineer, Friendster, Inc. > -----Original Message----- > From: cpp...@li... > [mailto:cpp...@li...] On > Behalf Of Divye Kapoor > Sent: Sunday, May 25, 2008 3:15 AM > To: C++ Networking Library Developers Mailing List > Subject: [cpp-netlib-devel] Bug(s) in http::client > > Hi, > I'm enclosing an attachment that illustrates loss of \n characters > while accessing data. The problem is due to the getline call on line > 72 of boost\network\protocol\http\client.hpp. The \n that is discarded > by the getline call is not put back into the body stream. > > To view the problem, run the http server using the server_cgi.py > script. (default port 8000) and then run bjam in the extracted > directory after setting the environment variable HTTPI_ROOT to the > path of the http_integration branch of cpp-netlib. > > The first test illustrates the loss of \n characters in the body of > the message and the second test shows that the body of a response is > not read at all. > > I have provided some cout statements to make the results of the test > run more obvious. Please view the results of accessing the URLs via a > web browser to see the difference. > > 1. The output of the first test can be corrected by adding an > additional \n character to the body string after every getline read. > However, I don't know if automatic character translation of newlines > takes place using the iostream interface of Boost.ASIO. If it does, > how do we handle newlines? Also, how will newlines be handled for > binary files? > > 2. I don't know why this test is failing as a web browser displays the > results correctly. Changing the test url to access any file in the > root directory (not the CGI script urls) yields the same result. Can > anybody throw more light on this problem please? > > I have only observed these problems on Windows Vista/VC8. I have not > tested this with other compilers and platforms. I would be grateful if > this bug could be verified for other platforms. > > A patch for making the first test case pass is: > Index: client.hpp > =================================================================== > --- client.hpp (revision 37) > +++ client.hpp (working copy) > @@ -70,7 +70,7 @@ > while (!socket_stream.eof()) { > typename string_traits<tag>::type line; > std::getline(socket_stream, line); > - body_stream << line; > + body_stream << line << '\n'; > }; > > response_ << body(body_stream.str()); > > > > Divye Kapoor > > PS: The attachment .bin file is actually a .zip file. Sourceforge is > currently blocking .zip attachments. > > -- > Whether the chicken crossed the road or the road moved beneath the > chicken depends upon your frame of reference. > My official web site: http://people.iitr.ernet.in/shp/061305/ > |