You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am attempting to use happy to implement a POST command using multipart/formdata using happyhttp (e.g., https://github.com/Zintinio/HappyHTTP) to upload files to droopy directly from a c++ application.
The issue is that the server will accept the POST command and create the file as requested, but it when trying to get the return page data. This is likely an interaction between some low-level implementation in droopy and in happyhttp, but a suitably-modified test case works for other servers, such as http://posttestserver.com/upload.php. Furthermore, the test code I have will work when pointed to a straight html page--it successfully downloads the page data.
The underlying situation is that happy tries to download the data, and although it knows there is outstanding data to process, it checks whether there is data waiting on the open socket and finds there is none. I don't really know what that means on the droopy side, but when I ctrl-c out of the program, droopy throws this error--this may not really be meaningful.
127.0.0.1 - - [02/Jun/2017 08:57:52] "POST / HTTP/1.1" 200 -
127.0.0.1 - - [02/Jun/2017 08:57:52] [Errno 32] Broken pipe
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 50762)
Traceback (most recent call last):
File "/usr/lib/python2.7/SocketServer.py", line 596, in process_request_thread
self.finish_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 331, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/lib/python2.7/SocketServer.py", line 654, in __init__
self.finish()
File "/usr/lib/python2.7/SocketServer.py", line 713, in finish
self.wfile.close()
File "/usr/lib/python2.7/socket.py", line 283, in close
self.flush()
File "/usr/lib/python2.7/socket.py", line 307, in flush
self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 32] Broken pipe
----------------------------------------
A happyhttp test case can be put into Test.cpp is as follows. Just add this after Test3.cpp, which can be compiled via g++ test.cpp happyhttp.cpp -o testpost
then, test with droopy running on localhost:8000
//This posts to local droopy server running on 8000
void Test4()
{
puts("-----------------Test4------------------------" );
// POST example using lower-level interface
const char* params = "--||||\nContent-Disposition: form-data; name=\"upfile\"; filename=\"testfile.txt\" \nContent-Type: application/octet-stream \n\nfile contents1\nfile contents2\nfile contents3\nfile contents4\nfile contents5\nfile contents6\nfile contents7\nfile contents8\nfile contents9\nfile contents10\n--||||--";
int l = strlen(params);
happyhttp::Connection conn( "localhost", 8000 );
conn.setcallbacks( OnBegin, OnData, OnComplete, 0 );
conn.putrequest( "POST", "/" );
conn.putheader( "Connection", "close" );
conn.putheader( "Content-Length", l );
conn.putheader( "Content-Type", "multipart/form-data; boundary=||||" );
conn.putheader( "Accept", "text/plain" );
conn.endheaders();
conn.send( (const unsigned char*)params, l );
while( conn.outstanding() )
{
conn.pump();
}
}
and later:
try
{
//Test1();
//Test2();
//Test3();
Test4();
}
The problem seems to be that outstanding() returns true, but when pump() is called, it returns on the datawaiting check:
if( !datawaiting( m_Sock ) )
return; // recv will block
I can't be sure whether happy or droopy are to blame; this works when pointed to posttestserver.com/upload.php, retrieving the custom response code; but fails on droopy. On the other hand, droopy works fine when used via a browser.
The text was updated successfully, but these errors were encountered:
I am attempting to use happy to implement a POST command using multipart/formdata using happyhttp (e.g., https://github.com/Zintinio/HappyHTTP) to upload files to droopy directly from a c++ application.
The issue is that the server will accept the POST command and create the file as requested, but it when trying to get the return page data. This is likely an interaction between some low-level implementation in droopy and in happyhttp, but a suitably-modified test case works for other servers, such as http://posttestserver.com/upload.php. Furthermore, the test code I have will work when pointed to a straight html page--it successfully downloads the page data.
The underlying situation is that happy tries to download the data, and although it knows there is outstanding data to process, it checks whether there is data waiting on the open socket and finds there is none. I don't really know what that means on the droopy side, but when I ctrl-c out of the program, droopy throws this error--this may not really be meaningful.
A happyhttp test case can be put into Test.cpp is as follows. Just add this after Test3.cpp, which can be compiled via g++ test.cpp happyhttp.cpp -o testpost
then, test with droopy running on localhost:8000
and later:
The problem seems to be that outstanding() returns true, but when pump() is called, it returns on the datawaiting check:
I can't be sure whether happy or droopy are to blame; this works when pointed to posttestserver.com/upload.php, retrieving the custom response code; but fails on droopy. On the other hand, droopy works fine when used via a browser.
The text was updated successfully, but these errors were encountered: