Ejemplo n.º 1
0
int HttpConnector::SendPostRequest(const char *path, const char* application, const char *dataBody)
{
	int bodySize =0;
	int len ;
	char *p ;
	char buf[8192] ;
	
	if (dataBody && dataBody[0]) {
		bodySize = (int)strlen(dataBody) ;
	}
	p = buf ;
	
	
	len = snprintf(p, sizeof(buf) , "POST /%s HTTP/1.1\r\nHost: %s:%d\r\n", path, m_host.c_str(),m_port );
	p += len ;
	
	len = snprintf(p, sizeof(buf) - (p-buf),"Accept: */*\r\n") ;
	p+= len ;
	
	len = snprintf(p, sizeof(buf) - (p-buf), "Content-Type:application/%s;charset=utf-8\r\n"
				   "Content-Length:%d\r\nConnection: Keep-Alive\r\n\r\n", application, bodySize );
	p += len;
	
	if (bodySize) {
		len = snprintf(p, sizeof(buf) - (p-buf), "%s\r\n\r\n" ,dataBody ) ;
		p += len ;
	}
	
	return nd_connector_raw_write(m_conn,buf, p-buf) ;
	//return m_conn->SendRawData(buf,p-buf) ;
	
}
Ejemplo n.º 2
0
int ndSendRaw(netObject netObj,char *data, int size)
{
    int ret = nd_connector_raw_write((nd_handle) netObj , data, (size_t) size) ;
	if (-1 == ret && NDERR_WOULD_BLOCK != nd_object_lasterror((nd_handle)netObj)) {
		tryto_terminate(netObj) ;
	}
	return ret ;
}
Ejemplo n.º 3
0
int HttpConnector::SendGetRequest(const char *path)
{
	int len ;
	char *p ;
	char buf[1024] ;
	
	p = buf ;
	
	len = snprintf(p, sizeof(buf) , "GET /%s HTTP/1.1\r\nHost: %s:%d\r\n\r\n", path, m_host.c_str(),m_port );
	p += len ;
	
	return nd_connector_raw_write(m_conn,buf, p-buf) ;
	//return m_conn->SendRawData(buf,p-buf) ;
}
Ejemplo n.º 4
0
RESULT_T apoCli_send(char *bufferFram, int frameSize)
{
	ApoClient *apoCli = ApoClient::getInstant();
	if (apoCli)	{
		if (! apoCli->IsInConnect())	{
			return NDSYS_ERR_CLOSED;
		}
		int ret = nd_connector_raw_write(apoCli->getConn(), bufferFram, frameSize);
		if (ret == -1)		{
			return (RESULT_T) nd_object_lasterror(apoCli->getConn());
		}
		return ESERVER_ERR_SUCCESS;
	}
	return NDSYS_ERR_NOT_INIT;
}