Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ MT-multithreading and servers » [FIXED]HttpRequest hangs when Chunked response, without trailer, and KeepAlive is set. (patch & TC)
Re: [BUG]HttpRequest hangs when Chunked response, without trailer, and KeepAlive is set. (patch & TC) [message #46325 is a reply to message #46292] Tue, 19 April 2016 11:42 Go to previous message
omari is currently offline  omari
Messages: 266
Registered: March 2010
Experienced Member
here a test case for chunker response with and without trailer:

#include <CtrlLib/CtrlLib.h>

using namespace Upp;

// base source : http://www.tcpipguide.com/free/t_HTTPDataLengthIssuesChunkedTransfersandMessageTrai-3.htm
String chunked_with_trailer = "HTTP/1.1 200 OK\r\nDate: Mon, 22 Mar 2004 11:15:03 GMT\r\nContent-Type: text/html\r\nTransfer-Encoding: chunked\r\nTrailer: Expires\r\n\r\n29\r\n<html><body><p>The file you requested is \r\n5\r\n3,400\r\n23\r\nbytes long and was last modified:\r\n\r\n1d\r\nSat, 20 Mar 2004 21:12:00 GMT\r\n13\r\n.</p></body></html>\r\n0\r\nExpires: Sat, 27 Mar 2004 21:12:00 GMT\r\n\r\n";

// base source : https://en.wikipedia.org/wiki/Chunked_transfer_encoding?oldid=430331176
String chunked_without_trailer = "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nTransfer-Encoding: chunked\r\n\r\n26\r\nThis is the data in the first chunk\r\n6\r\n1C\r\nand this is the second one\r\n\r\n3\r\ncon\r\n8\r\nsequence\r\n0\r\n\r\n";

static void Server(String r)
{
	TcpSocket   server;
	if(server.Listen(4000, 10)) {

		TcpSocket socket;
		LOG("Waiting...");
		bool b = socket.Accept(server);
		if(b) {
			LOG("Connection accepted");
			HttpHeader http;
			http.Read(socket);
			socket.Put(r);
			socket.Close();
		}
	}
}


GUI_APP_MAIN
{
	StdLogSetup(LOG_COUT|LOG_FILE);
	Thread a;

	LOG("chunked_without_trailer");
	LOG("****************");
	LOG(chunked_without_trailer);
	LOG("---------------");

	a.Run(callback1(Server, chunked_without_trailer));
	HttpRequest r1("localhost:4000");/*r1.Trace();*/	LOG(r1.GET().Execute());
	a.Wait();
	
	
	LOG("chunked_with_trailer");
	LOG("****************");
	LOG(chunked_with_trailer);
	LOG("---------------");

	a.Run(callback1(Server, chunked_with_trailer));
	HttpRequest r2("localhost:4000");/*r2.Trace();*/	LOG(r2.GET().Execute());
	a.Wait();

	LOG("=============== OK");
	
}



regards
omari.
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: HttpRequest : Add custon authentication capability
Next Topic: NTLM Authentication for HttpRequest
Goto Forum:
  


Current Time: Sat May 11 23:35:44 CEST 2024

Total time taken to generate the page: 0.02726 seconds