Пример #1
0
void mupnp_http_response_copy(mUpnpHttpResponse* destHttpRes, mUpnpHttpResponse* srcHttpRes)
{
  mupnp_log_debug_l4("Entering...\n");

  mupnp_http_response_setversion(destHttpRes, mupnp_http_response_getversion(srcHttpRes));
  mupnp_http_response_setstatuscode(destHttpRes, mupnp_http_response_getstatuscode(srcHttpRes));
  mupnp_http_response_setreasonphrase(destHttpRes, mupnp_http_response_getreasonphrase(srcHttpRes));

  mupnp_http_packet_copy((mUpnpHttpPacket*)destHttpRes, (mUpnpHttpPacket*)srcHttpRes);

  mupnp_log_debug_l4("Leaving...\n");
}
Пример #2
0
void mupnp_http_response_print(mUpnpHttpResponse* httpRes)
{
  mupnp_log_debug_l4("Entering...\n");

  mupnp_log_debug_s("%s %d %s\n",
      mupnp_http_response_getversion(httpRes),
      mupnp_http_response_getstatuscode(httpRes),
      mupnp_http_response_getreasonphrase(httpRes));

  mupnp_http_packet_print((mUpnpHttpPacket*)httpRes);

  mupnp_log_debug_l4("Leaving...\n");
}
Пример #3
0
mUpnpSoapResponse *mupnp_soap_request_post(mUpnpSoapRequest *soapReq, const char *ipaddr, int port)
{
	mUpnpHttpResponse *httpRes;
	char *content;
	size_t contentLen;
	mUpnpXmlParser *xmlParser;
	mUpnpHttpHeader *header = NULL;
	
	mupnp_log_debug_l4("Entering...\n");

	httpRes = mupnp_http_request_post(soapReq->httpReq, ipaddr, port);
	
	/* Check for HTTP response 405 Method Not Allowed */
	if (mupnp_http_response_getstatuscode(httpRes) == MUPNP_HTTP_STATUS_METHOD_NOT_ALLOWED)
	{
		/* Status code implies that we need to use M-POST */
		mupnp_http_request_setmethod(soapReq->httpReq, MUPNP_HTTP_MPOST);
		
		/* Add MAN header */
		header = mupnp_http_header_new();
		mupnp_http_header_setname(header, MUPNP_HTTP_MAN);
		mupnp_http_header_setvalue(header, MUPNP_HTTP_SOAP_MAN_VALUE);
		mupnp_http_packet_addheader((mUpnpHttpPacket*)soapReq->httpReq, header);
		
		/* Change soapaction header name to include namespace */
		header = mupnp_http_packet_getheader((mUpnpHttpPacket*)soapReq->httpReq, 
						  MUPNP_HTTP_SOAP_ACTION);
		if (header != NULL)
		{
			mupnp_http_header_setname(header, MUPNP_HTTP_SOAP_ACTION_WITH_NS);
		}
		
		/* New attempt */
		httpRes = mupnp_http_request_post(soapReq->httpReq, ipaddr, port);
	}
	
	mupnp_soap_response_sethttpresponse(soapReq->soapRes,httpRes);

	content = mupnp_http_response_getcontent(httpRes);
	contentLen = mupnp_http_response_getcontentlength(httpRes);
	if (content == NULL || contentLen <= 0)
		return soapReq->soapRes;

	xmlParser = mupnp_xml_parser_new();
	mupnp_xml_parse(xmlParser, soapReq->soapRes->rootNodeList, content, contentLen);
	mupnp_xml_parser_delete(xmlParser);

	mupnp_log_debug_l4("Leaving...\n");
	
	return soapReq->soapRes;
}