示例#1
0
void mupnp_http_headerlist_set(mUpnpHttpHeaderList *headerList, const char *name, const char *value)
{
	mUpnpHttpHeader *header;
	
	mupnp_log_debug_l4("Entering...\n");

	header = mupnp_http_headerlist_get(headerList, name);
	if (header == NULL) {
		header = mupnp_http_header_new();
		mupnp_http_headerlist_add(headerList, header);
		mupnp_http_header_setname(header, name);
	}
	
	mupnp_http_header_setvalue(header, value);

	mupnp_log_debug_l4("Leaving...\n");
}
示例#2
0
void mupnp_ssdp_packet_setheader(mUpnpSSDPPacket *ssdpPkt, char *ssdpMsg)
{
	mUpnpStringTokenizer *ssdpTok;
	mUpnpStringTokenizer *ssdpLineTok;
	mUpnpHttpHeader *header;
	char *lineMsg;
	char *name;
	char *value;
		
	mupnp_log_debug_l4("Entering...\n");

	ssdpTok = mupnp_string_tokenizer_new(ssdpMsg, MUPNP_HTTP_CRLF);

	/**** skip the first line ****/	
	if (mupnp_string_tokenizer_hasmoretoken(ssdpTok) == false)
		return;
	lineMsg = mupnp_string_tokenizer_nexttoken(ssdpTok);
	
	while (mupnp_string_tokenizer_hasmoretoken(ssdpTok) == true) {
		lineMsg = mupnp_string_tokenizer_nexttoken(ssdpTok);
		name = NULL;
		value = NULL;
		ssdpLineTok = mupnp_string_tokenizer_new(lineMsg, MUPNP_HTTP_HEADERLINE_DELIM);
		if (mupnp_string_tokenizer_hasmoretoken(ssdpLineTok) == true)
			name = mupnp_string_tokenizer_nexttoken(ssdpLineTok);
		if (mupnp_string_tokenizer_hasmoretoken(ssdpLineTok) == true) {
			value = mupnp_string_tokenizer_nextalltoken(ssdpLineTok);
			mupnp_strrtrim(value, MUPNP_HTTP_HEADERLINE_DELIM, mupnp_strlen(MUPNP_HTTP_HEADERLINE_DELIM));
		}
		if (name != NULL) {
			if (value == NULL)
				value = "";
			header = mupnp_http_header_new();
			mupnp_http_header_setname(header, name);
			mupnp_http_header_setvalue(header, value);
			mupnp_http_headerlist_add(ssdpPkt->headerList, header);
		}
		mupnp_string_tokenizer_delete(ssdpLineTok);
	}

	mupnp_string_tokenizer_delete(ssdpTok);

	mupnp_log_debug_l4("Leaving...\n");
}