Exemplo n.º 1
0
status_t
BEmailMessage::SetToRFC822(BPositionIO *mail_file, size_t length,
	bool parse_now)
{
	if (BFile *file = dynamic_cast<BFile *>(mail_file)) {
		file->ReadAttr(B_MAIL_ATTR_ACCOUNT_ID, B_INT32_TYPE, 0, &_account_id,
			sizeof(_account_id));
	}

	mail_file->Seek(0,SEEK_END);
	length = mail_file->Position();
	mail_file->Seek(0,SEEK_SET);

	_status = BMailComponent::SetToRFC822(mail_file,length,parse_now);
	if (_status < B_OK)
		return _status;

	_body = WhatIsThis();

	mail_file->Seek(0,SEEK_SET);
	_status = _body->SetToRFC822(mail_file,length,parse_now);
	if (_status < B_OK)
		return _status;

	//------------Move headers that we use to us, everything else to _body
	const char *name;
	for (int32 i = 0; (name = _body->HeaderAt(i)) != NULL; i++) {
		if (strcasecmp(name,"Subject") != 0
			&& strcasecmp(name,"To") != 0
			&& strcasecmp(name,"From") != 0
			&& strcasecmp(name,"Reply-To") != 0
			&& strcasecmp(name,"Cc") != 0
			&& strcasecmp(name,"Priority") != 0
			&& strcasecmp(name,"X-Priority") != 0
			&& strcasecmp(name,"X-Msmail-Priority") != 0
			&& strcasecmp(name,"Date") != 0) {
			RemoveHeader(name);
		}
	}

	_body->RemoveHeader("Subject");
	_body->RemoveHeader("To");
	_body->RemoveHeader("From");
	_body->RemoveHeader("Reply-To");
	_body->RemoveHeader("Cc");
	_body->RemoveHeader("Priority");
	_body->RemoveHeader("X-Priority");
	_body->RemoveHeader("X-Msmail-Priority");
	_body->RemoveHeader("Date");

	_num_components = 1;
	if (BMIMEMultipartMailContainer *container
			= dynamic_cast<BMIMEMultipartMailContainer *>(_body))
		_num_components = container->CountComponents();

	return B_OK;
}
Exemplo n.º 2
0
void CServerHttpResp::SetRespData( const char* resp_data , const int resp_size )
{
	// 移除content-length头
	RemoveHeader( "content-length" ) ;

	if ( resp_data == NULL || resp_size == 0 )
	{
		return ;
	}

	_sReqData.SetString( resp_data, resp_size ) ;

	char value_buf[100] ;
	sprintf( value_buf , "%d" , resp_size ) ;
	AddHeader( "content-length" , value_buf ) ;
}
Exemplo n.º 3
0
bool CHttpRequest::RemoveHeader(const CHttpHeader& header)
{
	return RemoveHeader(header.GetName());
}