Exemplo n.º 1
0
	// -----------------------------------------------------------------------
	//	AddContentFields
	// -----------------------------------------------------------------------
	void AddContentFields(HTTPHeader &header
						, const size_t content_length
						, const char *content_type
						, const char *charset)
	{
		string tmp = content_type;
		if (charset) tmp += string("; charset=") + charset;
		header.AddFieldString("Content-Type", tmp.c_str());
		header.AddFieldNumeric("Content-Length", content_length);
	}
Exemplo n.º 2
0
	// -----------------------------------------------------------------------
	//	AddRequestHeaderFields
	// -----------------------------------------------------------------------
	void AddRequestHeaderFields(HTTPHeader &header
							  , const O2Profile *profile)
	{
		string pubkey;
		profile->GetPubkeyA(pubkey);

		hashT hash;
		profile->GetID(hash);
		string hashstr;
		hash.to_string(hashstr);

		string flags;
		profile->GetFlags(flags);

		header.AddFieldString("Connection", "close");
		header.AddFieldString("Host", header.host.c_str());
		header.AddFieldString("User-Agent", profile->GetUserAgentA());
		header.AddFieldString(X_O2_NODE_ID, hashstr.c_str());
		header.AddFieldString(X_O2_RSAPUBLICKEY, pubkey.c_str());
		header.AddFieldNumeric(X_O2_PORT, profile->GetP2PPort());
		header.AddFieldString(X_O2_NODENAME, profile->GetNodeNameA());
		header.AddFieldString(X_O2_NODE_FLAGS, flags.c_str());
	}