Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of libMiMic by
cpp/HttpdConnection.cpp
- Committer:
- nyatla
- Date:
- 2013-04-04
- Revision:
- 4:909dc70956e7
- Child:
- 7:2b33a8d84eb3
File content as of revision 4:909dc70956e7:
#include "HttpdConnection.h"
namespace MiMic
{
HttpdConnection::HttpdConnection(NyLPC_TcHttpdConnection* i_ref_inst)
{
this->_ref_inst=i_ref_inst;
}
bool HttpdConnection::sendHeader(unsigned short i_status_code,const char* i_content_type,const char* i_additional_header)
{
return NyLPC_TBool_TRUE==NyLPC_cHttpdConnection_sendResponseHeader(this->_ref_inst,i_status_code,i_content_type,i_additional_header);
}
bool HttpdConnection::sendHeader(unsigned short i_status_code,const char* i_content_type,const char* i_additional_header,unsigned int i_length)
{
return NyLPC_TBool_TRUE==NyLPC_cHttpdConnection_sendResponseHeader2(this->_ref_inst,i_status_code,i_content_type,i_length,i_additional_header);
}
bool HttpdConnection::sendBody(const void* i_data,NyLPC_TUInt32 i_size)
{
return NyLPC_TBool_TRUE==NyLPC_cHttpdConnection_sendResponseBody(this->_ref_inst,i_data,i_size);
}
bool HttpdConnection::sendBodyF(const char* i_fmt,...)
{
va_list a;
if(this->_ref_inst->_res_status!=NyLPC_cHttpdConnection_ResStatus_BODY)
{
NyLPC_OnErrorGoto(Error);
}
//Bodyの書込み
va_start(a,i_fmt);
if(!NyLPC_cHttpBodyWriter_formatV(&(this->_ref_inst->_body_writer),i_fmt,a)){
NyLPC_OnErrorGoto(Error_Send);
}
va_end(a);
return true;
Error_Send:
va_end(a);
NyLPC_cHttpBodyWriter_finalize(&(this->_ref_inst->_in_stream));
Error:
this->_ref_inst->_res_status=NyLPC_cHttpdConnection_ResStatus_ERROR;
return false;
}
}
