From: Divye K. <div...@gm...> - 2008-05-24 19:14:42
|
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/ |