Exemple #1
0
CgHttpRequest *cg_http_request_new()
{
    CgHttpRequest *httpReq;

    cg_log_debug_l4("Entering...\n");

    httpReq = (CgHttpRequest *)malloc(sizeof(CgHttpRequest));

    if ( NULL != httpReq )
    {
        cg_http_packet_init((CgHttpPacket *)httpReq);
        httpReq->method = cg_string_new();
        httpReq->version = cg_string_new();
        httpReq->uri = cg_string_new();
        httpReq->userAgent = cg_string_new();
        httpReq->httpRes = cg_http_response_new();
        httpReq->postURL = cg_net_url_new();

        cg_http_request_setversion(httpReq, CG_HTTP_VER11);
        cg_http_request_setuseragent(httpReq, CG_HTTP_USERAGENT_DEFAULT);

        cg_http_request_setsocket(httpReq, NULL);
        cg_http_request_setuserdata(httpReq, NULL);

        cg_http_request_settimeout(httpReq, CG_HTTP_CONN_TIMEOUT);
    }

    cg_log_debug_l4("Leaving...\n");

    return httpReq;
}
Exemple #2
0
static CgUpnpDevice *cg_upnp_controlpoint_createdevicefromssdkpacket(CgUpnpSSDPPacket *ssdpPkt)
{
	const char *location;
	CgNetURL *url;
	CgUpnpDevice *dev;
	BOOL parseSuccess;
	
	cg_log_debug_l4("Entering...\n");

	location = cg_upnp_ssdp_packet_getlocation(ssdpPkt);
	if (cg_strlen(location) <= 0)
		return NULL;
			
	dev = cg_upnp_device_new();
	
	url = cg_net_url_new();
	cg_net_url_set(url, location);
	parseSuccess =  cg_upnp_device_parsedescriptionurl(dev, url);
	cg_net_url_delete(url);
	
	if (parseSuccess == FALSE) {
		cg_upnp_device_delete(dev);
		return NULL;
	}

	cg_upnp_device_setssdppacket(dev, ssdpPkt);

#ifndef CG_OPTIMIZED_CP_MODE
	if (cg_upnp_controlpoint_parseservicesfordevice(dev, ssdpPkt) == FALSE)
	{
		cg_upnp_device_delete(dev);
		return NULL;
	}
#endif
	
	cg_log_debug_l4("Leaving...\n");

	return dev;
}