当前位置: 首页>>代码示例>>C++>>正文


C++ soup_message_headers_get_one函数代码示例

本文整理汇总了C++中soup_message_headers_get_one函数的典型用法代码示例。如果您正苦于以下问题:C++ soup_message_headers_get_one函数的具体用法?C++ soup_message_headers_get_one怎么用?C++ soup_message_headers_get_one使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了soup_message_headers_get_one函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: received_announcement

static void
received_announcement (GSSDPResourceBrowser *resource_browser,
                       SoupMessageHeaders   *headers)
{
        const char *header;

        header = soup_message_headers_get_one (headers, "NT");
        if (!header)
                return; /* No target specified */

        if (!check_target_compat (resource_browser, header))
                return; /* Target doesn't match */

        header = soup_message_headers_get_one (headers, "NTS");
        if (!header)
                return; /* No announcement type specified */

        /* Check announcement type */
        if      (strncmp (header,
                          SSDP_ALIVE_NTS,
                          strlen (SSDP_ALIVE_NTS)) == 0)
                resource_available (resource_browser, headers);
        else if (strncmp (header,
                          SSDP_BYEBYE_NTS,
                          strlen (SSDP_BYEBYE_NTS)) == 0)
                resource_unavailable (resource_browser, headers);
        else if (strncmp (header,
                          SSDP_UPDATE_NTS,
                          strlen (SSDP_UPDATE_NTS)) == 0)
                resource_update (resource_browser, headers);
}
开发者ID:GNOME,项目名称:gssdp,代码行数:31,代码来源:gssdp-resource-browser.c

示例2: resource_update

static void
resource_update (GSSDPResourceBrowser *resource_browser,
                 SoupMessageHeaders   *headers)
{
        GSSDPResourceBrowserPrivate *priv;
        const char *usn;
        const char *boot_id_header;
        const char *next_boot_id_header;
        char *canonical_usn;
        guint boot_id;
        guint next_boot_id;
        gint64 out;

        priv = gssdp_resource_browser_get_instance_private (resource_browser);
        usn = soup_message_headers_get_one (headers, "USN");
        boot_id_header = soup_message_headers_get_one (headers, "BOOTID.UPNP.ORG");
        next_boot_id_header = soup_message_headers_get_one (headers, "NEXTBOOTID.UPNP.ORG");

        if (!usn)
                return; /* No USN specified */

        if (!boot_id_header)
                return;

        if (!next_boot_id_header)
                return;

        if (!g_ascii_string_to_signed (boot_id_header, 10, 0, G_MAXINT32, &out, NULL))
                return;
        boot_id = out;

        if (!g_ascii_string_to_signed (next_boot_id_header, 10, 0, G_MAXINT32, &out, NULL))
                return;
        next_boot_id = out;

        if (priv->version > 0) {
                char *version;
                version = g_strrstr (usn, ":");
                canonical_usn = g_strndup (usn, version - usn);
        } else {
                canonical_usn = g_strdup (usn);
        }

        /* Only continue if we know about this. if not, there will be an
         * announcement afterwards anyway */
        if (!g_hash_table_lookup (priv->resources,
                                  canonical_usn))
                goto out;

        g_signal_emit (resource_browser,
                       signals[RESOURCE_UPDATE],
                       0,
                       usn,
                       boot_id,
                       next_boot_id);
out:
        g_free (canonical_usn);

}
开发者ID:GNOME,项目名称:gssdp,代码行数:59,代码来源:gssdp-resource-browser.c

示例3: multipart_read_headers

/*
 *  * We have two headeers we care about, Content-ID which we use as steam_type and
 *   * Status which we read when stream_type equals STREAM_ERROR.
 *    */
static void
multipart_read_headers (MultiPartData *multipart_data)
{
    multipart_data->headers = soup_multipart_input_stream_get_headers (multipart_data->multipart);
    if (multipart_data->headers) {
        multipart_data->method = soup_message_headers_get_one (multipart_data->headers, "rstrnt-method");
        multipart_data->path = soup_message_headers_get_one (multipart_data->headers, "rstrnt-path");
    }
}
开发者ID:jbastian,项目名称:restraint,代码行数:13,代码来源:multipart.c

示例4: is_websocket_client

static gboolean
is_websocket_client (SnraServerClient * client)
{
    /* Check for request headers. Example:
     * Upgrade: websocket
     * Connection: Upgrade, Keep-Alive
     * Sec-WebSocket-Key: XYZABC123
     * Sec-WebSocket-Protocol: aurena
     * Sec-WebSocket-Version: 13
     */
    SoupMessage *msg = client->event_pipe;
    SoupMessageHeaders *req_hdrs = msg->request_headers;
    const gchar *val;
    gint protocol_ver = 0;

    if ((val = soup_message_headers_get_one (req_hdrs, "Upgrade")) == NULL)
        return FALSE;
    if (g_ascii_strcasecmp (val, "websocket") != 0)
        return FALSE;
    if ((val = soup_message_headers_get_list (req_hdrs, "Connection")) == NULL)
        return FALSE;

    /* Connection params list must request upgrade to websocket */
    if (!http_list_contains_value (val, "upgrade"))
        return FALSE;

    if ((val =
                soup_message_headers_get_one (req_hdrs, "Sec-WebSocket-Key")) == NULL)
        return FALSE;
    if ((val =
                soup_message_headers_get_list (req_hdrs,
                        "Sec-WebSocket-Protocol")) == NULL)
        return FALSE;

    if (!http_list_contains_value (val, "aurena"))
        return FALSE;

    /* Requested protocol version must be 13 or 8 */
    if ((val = soup_message_headers_get_list (req_hdrs,
               "Sec-WebSocket-Version")) == NULL)
        return FALSE;

    if (http_list_contains_value (val, "13"))
        protocol_ver = 13;
    else if (http_list_contains_value (val, "8"))
        protocol_ver = 8;

    if (protocol_ver == 0)
        return FALSE;               /* No supported version found */

    g_print ("WebSocket connection with protocol %d\n", protocol_ver);
    client->websocket_protocol = protocol_ver;

    return TRUE;
}
开发者ID:elisescu,项目名称:aurena,代码行数:55,代码来源:snra-server-client.c

示例5: request_started

static void
request_started (SoupSession *session, SoupMessage *msg,
		 SoupSocket *socket)
{
	if (soup_message_headers_get_one (msg->request_headers,
					  "If-Modified-Since") ||
	    soup_message_headers_get_one (msg->request_headers,
					  "If-None-Match")) {
		debug_printf (2, "    Conditional request for %s\n",
			      soup_message_get_uri (msg)->path);
		last_request_validated = TRUE;
	}
}
开发者ID:Kharif,项目名称:libsoup,代码行数:13,代码来源:cache-test.c

示例6: check_response

static void
check_response (SoupMessage *msg,
		const char *expected_encoding,
		const char *expected_content_type,
		MessageContentStatus status)
{
	const char *coding, *type;

	if (!SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) {
		debug_printf (1, "    Unexpected status %d %s\n",
			      msg->status_code, msg->reason_phrase);
		errors++;
	}

	coding = soup_message_headers_get_one (msg->response_headers, "Content-Encoding");
	if (expected_encoding) {
		if (!coding || g_ascii_strcasecmp (coding, expected_encoding) != 0) {
			debug_printf (1, "    Unexpected Content-Encoding: %s\n",
				      coding ? coding : "(none)");
			errors++;
		}
	} else {
		if (coding) {
			debug_printf (1, "    Unexpected Content-Encoding: %s\n",
				      coding);
			errors++;
		}
	}

	if (status != NO_CHECK) {
		if (status == EXPECT_DECODED) {
			if (!(soup_message_get_flags (msg) & SOUP_MESSAGE_CONTENT_DECODED)) {
				debug_printf (1, "    SOUP_MESSAGE_CONTENT_DECODED not set!\n");
				errors++;
			}
		} else {
			if (soup_message_get_flags (msg) & SOUP_MESSAGE_CONTENT_DECODED) {
				debug_printf (1, "    SOUP_MESSAGE_CONTENT_DECODED set!\n");
				errors++;
			}
		}
	}

	type = soup_message_headers_get_one (msg->response_headers, "Content-Type");
	if (!type || g_ascii_strcasecmp (type, expected_content_type) != 0) {
		debug_printf (1, "    Unexpected Content-Type: %s\n",
			      type ? type : "(none)");
		errors++;
	}
}
开发者ID:NEVERMOR,项目名称:libsoup,代码行数:50,代码来源:coding-test.c

示例7: soup_message_headers_get_encoding

/**
 * soup_message_headers_get_encoding:
 * @hdrs: a #SoupMessageHeaders
 *
 * Gets the message body encoding that @hdrs declare. This may not
 * always correspond to the encoding used on the wire; eg, a HEAD
 * response may declare a Content-Length or Transfer-Encoding, but
 * it will never actually include a body.
 *
 * Return value: the encoding declared by @hdrs.
 **/
SoupEncoding
soup_message_headers_get_encoding (SoupMessageHeaders *hdrs)
{
	const char *header;

	if (hdrs->encoding != -1)
		return hdrs->encoding;

	/* If Transfer-Encoding was set, hdrs->encoding would already
	 * be set. So we don't need to check that possibility.
	 */
	header = soup_message_headers_get_one (hdrs, "Content-Length");
	if (header) {
		content_length_setter (hdrs, header);
		if (hdrs->encoding != -1)
			return hdrs->encoding;
	}

	/* Per RFC 2616 4.4, a response body that doesn't indicate its
	 * encoding otherwise is terminated by connection close, and a
	 * request that doesn't indicate otherwise has no body. Note
	 * that SoupMessage calls soup_message_headers_set_encoding()
	 * to override the response body default for our own
	 * server-side messages.
	 */
	hdrs->encoding = (hdrs->type == SOUP_MESSAGE_HEADERS_RESPONSE) ?
		SOUP_ENCODING_EOF : SOUP_ENCODING_NONE;
	return hdrs->encoding;
}
开发者ID:tizenorg,项目名称:framework.connectivity.libsoup2.4,代码行数:40,代码来源:soup-message-headers.c

示例8: do_aliases_test_for_session

static void
do_aliases_test_for_session (SoupSession *session,
			     const char *redirect_protocol)
{
	SoupMessage *msg;
	SoupURI *uri;
	const char *redirected_protocol;

	uri = soup_uri_new_with_base (base_uri, "/alias-redirect");
	msg = soup_message_new_from_uri ("GET", uri);
	if (redirect_protocol)
		soup_message_headers_append (msg->request_headers, "X-Redirect-Protocol", redirect_protocol);
	soup_uri_free (uri);
	soup_session_send_message (session, msg);

	redirected_protocol = soup_message_headers_get_one (msg->response_headers, "X-Redirected-Protocol");

	if (g_strcmp0 (redirect_protocol, redirected_protocol)) {
		debug_printf (1, "    redirect went to %s, should have gone to %s!\n",
			      redirected_protocol ? redirected_protocol : "(none)",
			      redirect_protocol ? redirect_protocol : "(none)");
		errors++;
	} else if (redirect_protocol && !SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) {
		debug_printf (1, "    msg failed? (%d %s)\n",
			      msg->status_code, msg->reason_phrase);
		errors++;
	} else if (!redirect_protocol && SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) {
		debug_printf (1, "    msg succeeded? (%d %s)\n",
			      msg->status_code, msg->reason_phrase);
		errors++;
	}

	g_object_unref (msg);
}
开发者ID:Kharif,项目名称:libsoup,代码行数:34,代码来源:misc-test.c

示例9: ipv6_server_callback

static void
ipv6_server_callback (SoupServer *server, SoupMessage *msg,
		      const char *path, GHashTable *query,
		      SoupClientContext *context, gpointer data)
{
	const char *host;
	char expected_host[128];

	host = soup_message_headers_get_one (msg->request_headers, "Host");
	if (!host) {
		debug_printf (1, "    request has no Host header!\n");
		errors++;
		soup_message_set_status (msg, SOUP_STATUS_BAD_REQUEST);
		return;
	}

	g_snprintf (expected_host, sizeof (expected_host),
		    "[::1]:%d", soup_server_get_port (server));

	if (strcmp (host, expected_host) == 0)
		soup_message_set_status (msg, SOUP_STATUS_OK);
	else {
		debug_printf (1, "    request has incorrect Host header '%s'\n", host);
		errors++;
		soup_message_set_status (msg, SOUP_STATUS_BAD_REQUEST);
	}
}
开发者ID:Kharif,项目名称:libsoup,代码行数:27,代码来源:misc-test.c

示例10: contentSniffedCallback

static void contentSniffedCallback(SoupMessage* msg, const char* sniffedType, GHashTable *params, gpointer data)
{
    if (sniffedType) {
        const char* officialType = soup_message_headers_get_one(msg->response_headers, "Content-Type");

        if (!officialType || strcmp(officialType, sniffedType))
            soup_message_headers_set_content_type(msg->response_headers, sniffedType, params);
    }

    // The 304 status code (SOUP_STATUS_NOT_MODIFIED) needs to be fed
    // into WebCore, as opposed to other kinds of redirections, which
    // are handled by soup directly, so we special-case it here and in
    // gotChunk.
    if (SOUP_STATUS_IS_TRANSPORT_ERROR(msg->status_code)
        || (SOUP_STATUS_IS_REDIRECTION(msg->status_code) && (msg->status_code != SOUP_STATUS_NOT_MODIFIED))
        || (msg->status_code == SOUP_STATUS_UNAUTHORIZED))
        return;

    RefPtr<ResourceHandle> handle = static_cast<ResourceHandle*>(data);
    if (!handle)
        return;
    ResourceHandleInternal* d = handle->getInternal();
    if (d->m_cancelled)
        return;
    ResourceHandleClient* client = handle->client();
    if (!client)
        return;

    fillResponseFromMessage(msg, &d->m_response);
    client->didReceiveResponse(handle.get(), d->m_response);
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:31,代码来源:ResourceHandleSoup.cpp

示例11: authentication_info_cb

static void
authentication_info_cb (SoupMessage *msg, gpointer data)
{
	SoupAuth *auth = data;
	SoupAuthDigestPrivate *priv = SOUP_AUTH_DIGEST_GET_PRIVATE (auth);
	const char *header;
	GHashTable *auth_params;
	char *nextnonce;

	if (auth != soup_message_get_auth (msg))
		return;

	header = soup_message_headers_get_one (msg->response_headers,
					       soup_auth_is_for_proxy (auth) ?
					       "Proxy-Authentication-Info" :
					       "Authentication-Info");
	g_return_if_fail (header != NULL);

	auth_params = soup_header_parse_param_list (header);
	if (!auth_params)
		return;

	nextnonce = g_strdup (g_hash_table_lookup (auth_params, "nextnonce"));
	if (nextnonce) {
		g_free (priv->nonce);
		priv->nonce = nextnonce;
	}

	soup_header_free_param_list (auth_params);
}
开发者ID:Distrotech,项目名称:libsoup,代码行数:30,代码来源:soup-auth-digest.c

示例12: contentSniffedCallback

// This callback will not be called if the content sniffer is disabled in startHttp.
static void contentSniffedCallback(SoupMessage* msg, const char* sniffedType, GHashTable *params, gpointer data)
{
    if (sniffedType) {
        const char* officialType = soup_message_headers_get_one(msg->response_headers, "Content-Type");

        if (!officialType || strcmp(officialType, sniffedType))
            soup_message_headers_set_content_type(msg->response_headers, sniffedType, params);
    }

    if (statusWillBeHandledBySoup(msg->status_code))
        return;

    RefPtr<ResourceHandle> handle = static_cast<ResourceHandle*>(data);
    if (!handle)
        return;
    ResourceHandleInternal* d = handle->getInternal();
    if (d->m_cancelled)
        return;
    ResourceHandleClient* client = handle->client();
    if (!client)
        return;

    fillResponseFromMessage(msg, &d->m_response);
    client->didReceiveResponse(handle.get(), d->m_response);
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:26,代码来源:ResourceHandleSoup.cpp

示例13: identify_auth

static int
identify_auth (SoupMessage *msg)
{
	const char *header;
	int num;

	header = soup_message_headers_get_one (msg->request_headers,
					       "Authorization");
	if (!header)
		return 0;

	if (!g_ascii_strncasecmp (header, "Basic ", 6)) {
		char *token;
		gsize len;

		token = (char *)g_base64_decode (header + 6, &len);
		num = token[len - 1] - '0';
		g_free (token);
	} else {
		const char *user;

		user = strstr (header, "username=\"user");
		if (user)
			num = user[14] - '0';
		else
			num = 0;
	}

	g_assert (num >= 0 && num <= 4);

	return num;
}
开发者ID:Conservatory,项目名称:quark,代码行数:32,代码来源:auth-test.c

示例14: utils_download_picture_if_newer

GdkPixbuf*
utils_download_picture_if_newer(SoupSession* soup, const gchar* url, gint64 timestamp)
{
    SoupMessage* msg;
    guint soup_status;
    const gchar* last_modified;
    GdkPixbuf* ret;

    msg = soup_message_new(SOUP_METHOD_HEAD, url);
    soup_status = soup_session_send_message(soup, msg);

    if (SOUP_STATUS_IS_SUCCESSFUL(soup_status) &&
        (last_modified = soup_message_headers_get_one(msg->response_headers, "Last-Modified")) != NULL &&
        utils_http_full_date_to_timestamp(last_modified) < timestamp)
    {
        g_info("{Utils} No new content at url '%s'", url);
        ret = NULL;
    }
    else
        ret = utils_download_picture(soup, url);

    g_object_unref(msg);

    return ret;
}
开发者ID:EliVerbrugge,项目名称:gnome-twitch,代码行数:25,代码来源:utils.c

示例15: serverCallback

static void serverCallback(SoupServer* server, SoupMessage* message, const char* path, GHashTable*, SoupClientContext*, gpointer)
{
    if (message->method != SOUP_METHOD_GET) {
        soup_message_set_status(message, SOUP_STATUS_NOT_IMPLEMENTED);
        return;
    }

    if (g_str_equal(path, "/")) {
        const char* acceptLanguage = soup_message_headers_get_one(message->request_headers, "Accept-Language");
        soup_message_set_status(message, SOUP_STATUS_OK);
        soup_message_body_append(message->response_body, SOUP_MEMORY_COPY, acceptLanguage, strlen(acceptLanguage));
        soup_message_body_complete(message->response_body);
    } else if (g_str_equal(path, "/empty")) {
        const char* emptyHTML = "<html><body></body></html>";
        soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, emptyHTML, strlen(emptyHTML));
        soup_message_body_complete(message->response_body);
        soup_message_set_status(message, SOUP_STATUS_OK);
    } else if (g_str_equal(path, "/appcache")) {
        const char* appcacheHTML = "<html manifest=appcache.manifest><body></body></html>";
        soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, appcacheHTML, strlen(appcacheHTML));
        soup_message_body_complete(message->response_body);
        soup_message_set_status(message, SOUP_STATUS_OK);
    } else if (g_str_equal(path, "/appcache.manifest")) {
        const char* appcacheManifest = "CACHE MANIFEST\nCACHE:\nappcache/foo.txt\n";
        soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, appcacheManifest, strlen(appcacheManifest));
        soup_message_body_complete(message->response_body);
        soup_message_set_status(message, SOUP_STATUS_OK);
    } else if (g_str_equal(path, "/appcache/foo.txt")) {
        soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, "foo", 3);
        soup_message_body_complete(message->response_body);
        soup_message_set_status(message, SOUP_STATUS_OK);
    } else
        soup_message_set_status(message, SOUP_STATUS_NOT_FOUND);
}
开发者ID:ollie314,项目名称:webkit,代码行数:34,代码来源:TestWebKitWebContext.cpp


注:本文中的soup_message_headers_get_one函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。