这篇教程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函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: received_announcementstatic voidreceived_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,
示例2: resource_updatestatic voidresource_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,
示例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 voidmultipart_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,
示例4: is_websocket_clientstatic gbooleanis_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,
示例5: request_startedstatic voidrequest_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,
示例6: check_responsestatic voidcheck_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,
示例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. **/SoupEncodingsoup_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,
示例8: do_aliases_test_for_sessionstatic voiddo_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,
示例9: ipv6_server_callbackstatic voidipv6_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,
示例10: contentSniffedCallbackstatic 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,
示例11: authentication_info_cbstatic voidauthentication_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,
示例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,
示例13: identify_authstatic intidentify_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,
示例14: utils_download_picture_if_newerGdkPixbuf*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,
示例15: serverCallbackstatic 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,
示例16: do_putstatic voiddo_put (SoupServer *server, SoupMessage *msg, const char *path){ struct stat st; FILE *f; gboolean created = TRUE; if (stat (path, &st) != -1) { const char *match = soup_message_headers_get_one (msg->request_headers, "If-None-Match"); if (match && !strcmp (match, "*")) { soup_message_set_status (msg, SOUP_STATUS_CONFLICT); return; } if (!S_ISREG (st.st_mode)) { soup_message_set_status (msg, SOUP_STATUS_FORBIDDEN); return; } created = FALSE; } f = fopen (path, "w"); if (!f) { soup_message_set_status (msg, SOUP_STATUS_INTERNAL_SERVER_ERROR); return; } fwrite (msg->request_body->data, 1, msg->request_body->length, f); fclose (f); soup_message_set_status (msg, created ? SOUP_STATUS_CREATED : SOUP_STATUS_OK);}
开发者ID:Distrotech,项目名称:libsoup,代码行数:33,
示例17: soup_message_get_urivoid ResourceResponse::updateFromSoupMessage(SoupMessage* soupMessage){ SoupURI* soupURI = soup_message_get_uri(soupMessage); GOwnPtr<gchar> uri(soup_uri_to_string(soupURI, FALSE)); m_url = KURL(KURL(), String::fromUTF8(uri.get())); m_httpStatusCode = soupMessage->status_code; SoupMessageHeadersIter headersIter; const char* headerName; const char* headerValue; soup_message_headers_iter_init(&headersIter, soupMessage->response_headers); while (soup_message_headers_iter_next(&headersIter, &headerName, &headerValue)) m_httpHeaderFields.set(String::fromUTF8(headerName), String::fromUTF8(headerValue)); m_soupFlags = soup_message_get_flags(soupMessage); String contentType = soup_message_headers_get_one(soupMessage->response_headers, "Content-Type"); setMimeType(extractMIMETypeFromMediaType(contentType)); setTextEncodingName(extractCharsetFromMediaType(contentType)); setExpectedContentLength(soup_message_headers_get_content_length(soupMessage->response_headers)); setHTTPStatusText(soupMessage->reason_phrase); setSuggestedFilename(filenameFromHTTPContentDisposition(httpHeaderField("Content-Disposition")));}
开发者ID:azrul2202,项目名称:WebKit-Smartphone,代码行数:26,
示例18: check_passwordstatic gbooleancheck_password (SoupAuthDomain *domain, SoupMessage *msg, const char *username, const char *password){ const char *header; GHashTable *params; const char *msg_username; char hex_urp[33]; gboolean accept; header = soup_message_headers_get_one (msg->request_headers, "Authorization"); if (strncmp (header, "Digest ", 7) != 0) return FALSE; params = soup_header_parse_param_list (header + 7); if (!params) return FALSE; msg_username = g_hash_table_lookup (params, "username"); if (!msg_username || strcmp (msg_username, username) != 0) { soup_header_free_param_list (params); return FALSE; } soup_auth_digest_compute_hex_urp (username, soup_auth_domain_get_realm (domain), password, hex_urp); accept = check_hex_urp (domain, msg, params, username, hex_urp); soup_header_free_param_list (params); return accept;}
开发者ID:BabaNina,项目名称:libsoup,代码行数:34,
示例19: callbackstatic voidcallback (SoupSession * session, SoupMessage * msg, gpointer user_data){ GstSoupHttpClientSink *souphttpsink = GST_SOUP_HTTP_CLIENT_SINK (user_data); GST_DEBUG_OBJECT (souphttpsink, "callback status=%d %s", msg->status_code, msg->reason_phrase); g_mutex_lock (&souphttpsink->mutex); g_cond_signal (&souphttpsink->cond); souphttpsink->message = NULL; if (!SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) { souphttpsink->failures++; if (souphttpsink->retries && (souphttpsink->retries < 0 || souphttpsink->retries >= souphttpsink->failures)) { guint64 retry_delay; const char *retry_after = soup_message_headers_get_one (msg->response_headers, "Retry-After"); if (retry_after) { gchar *end = NULL; retry_delay = g_ascii_strtoull (retry_after, &end, 10); if (end || errno) { retry_delay = souphttpsink->retry_delay; } else { retry_delay = MAX (retry_delay, souphttpsink->retry_delay); } GST_WARNING_OBJECT (souphttpsink, "Could not write to HTTP URI: " "status: %d %s (retrying PUT after %" G_GINT64_FORMAT " seconds with Retry-After: %s)", msg->status_code, msg->reason_phrase, retry_delay, retry_after); } else { retry_delay = souphttpsink->retry_delay; GST_WARNING_OBJECT (souphttpsink, "Could not write to HTTP URI: " "status: %d %s (retrying PUT after %" G_GINT64_FORMAT " seconds)", msg->status_code, msg->reason_phrase, retry_delay); } souphttpsink->timer = g_timeout_source_new_seconds (retry_delay); g_source_set_callback (souphttpsink->timer, (GSourceFunc) (send_message), souphttpsink, NULL); g_source_attach (souphttpsink->timer, souphttpsink->context); } else { souphttpsink->status_code = msg->status_code; souphttpsink->reason_phrase = g_strdup (msg->reason_phrase); } g_mutex_unlock (&souphttpsink->mutex); return; } g_list_free_full (souphttpsink->sent_buffers, (GDestroyNotify) gst_buffer_unref); souphttpsink->sent_buffers = NULL; souphttpsink->failures = 0; send_message_locked (souphttpsink); g_mutex_unlock (&souphttpsink->mutex);}
开发者ID:ConfusedReality,项目名称:pkg_multimedia_gst-plugins-good,代码行数:59,
示例20: databases_items_xxxstatic voiddatabases_items_xxx (DMAPShare * share, SoupServer * server, SoupMessage * msg, const char *path, GHashTable * query, SoupClientContext * context){ DMAPDb *db; const gchar *transcode_mimetype; const gchar *rest_of_path; const gchar *id_str; guint id; const gchar *range_header; guint64 filesize; guint64 offset = 0; DAAPRecord *record; rest_of_path = strchr (path + 1, '/'); id_str = rest_of_path + 9; id = strtoul (id_str, NULL, 10); g_object_get (share, "db", &db, NULL); record = DAAP_RECORD (dmap_db_lookup_by_id (db, id)); g_object_get (record, "filesize", &filesize, NULL); DMAP_SHARE_GET_CLASS (share)->message_add_standard_headers (share, msg); soup_message_headers_append (msg->response_headers, "Accept-Ranges", "bytes"); range_header = soup_message_headers_get_one (msg->request_headers, "Range"); if (range_header) { const gchar *s; gchar *content_range; s = range_header + 6; /* bytes= */ offset = atoll (s); content_range = g_strdup_printf ("bytes %" G_GUINT64_FORMAT "-%" G_GUINT64_FORMAT "/%" G_GUINT64_FORMAT, offset, filesize, filesize); soup_message_headers_append (msg->response_headers, "Content-Range", content_range); g_debug ("Content range is %s.", content_range); g_free (content_range); soup_message_set_status (msg, SOUP_STATUS_PARTIAL_CONTENT); } else { soup_message_set_status (msg, SOUP_STATUS_OK); } g_object_get (share, "transcode-mimetype", &transcode_mimetype, NULL); send_chunked_file (server, msg, record, filesize, offset, transcode_mimetype); g_object_unref (record);}
开发者ID:KOLYaNYChCh,项目名称:libdmapsharing,代码行数:58,
示例21: network_process_callbackstatic voidnetwork_process_callback (SoupSession *session, SoupMessage *msg, gpointer user_data){ updateJobPtr job = (updateJobPtr)user_data; SoupDate *last_modified; const gchar *tmp = NULL; job->result->source = soup_uri_to_string (soup_message_get_uri(msg), FALSE); if (SOUP_STATUS_IS_TRANSPORT_ERROR (msg->status_code)) { job->result->returncode = msg->status_code; job->result->httpstatus = 0; } else { job->result->httpstatus = msg->status_code; job->result->returncode = 0; } debug1 (DEBUG_NET, "download status code: %d", msg->status_code); debug1 (DEBUG_NET, "source after download: >>>%s<<<", job->result->source); job->result->data = g_memdup (msg->response_body->data, msg->response_body->length+1); job->result->size = (size_t)msg->response_body->length; debug1 (DEBUG_NET, "%d bytes downloaded", job->result->size); job->result->contentType = g_strdup (soup_message_headers_get_content_type (msg->response_headers, NULL)); /* Update last-modified date */ tmp = soup_message_headers_get_one (msg->response_headers, "Last-Modified"); if (tmp) { /* The string may be badly formatted, which will make * soup_date_new_from_string() return NULL */ last_modified = soup_date_new_from_string (tmp); if (last_modified) { job->result->updateState->lastModified = soup_date_to_time_t (last_modified); soup_date_free (last_modified); } } /* Update ETag value */ tmp = soup_message_headers_get_one (msg->response_headers, "ETag"); if (tmp) { job->result->updateState->etag = g_strdup(tmp); } update_process_finished_job (job);}
开发者ID:gcampax,项目名称:liferea,代码行数:45,
示例22: disappear_request_readstatic voiddisappear_request_read (SoupServer *server, SoupMessage *msg, SoupClientContext *context, gpointer user_data){ /* Remove the WWW-Authenticate header if this was a failed attempt */ if (soup_message_headers_get_one (msg->request_headers, "Authorization") && msg->status_code == SOUP_STATUS_UNAUTHORIZED) soup_message_headers_remove (msg->response_headers, "WWW-Authenticate");}
开发者ID:simonmiddleton,项目名称:libsoup,代码行数:9,
示例23: snra_server_client_newSnraServerClient *snra_server_client_new (SoupServer * soup, SoupMessage * msg, SoupClientContext * context){ SnraServerClient *client = g_object_new (SNRA_TYPE_SERVER_CLIENT, NULL); const gchar *accept_challenge; gchar *accept_reply; client->soup = soup; client->event_pipe = msg; client->host = g_strdup (soup_client_context_get_host (context)); client->net_event_sig = g_signal_connect (msg, "network-event", G_CALLBACK (snra_server_client_network_event), client); client->disco_sig = g_signal_connect (msg, "finished", G_CALLBACK (snra_server_client_disconnect), client); if (!is_websocket_client (client)) { client->type = SNRA_SERVER_CLIENT_CHUNKED; client->need_body_complete = TRUE; soup_message_headers_set_encoding (msg->response_headers, SOUP_ENCODING_CHUNKED); soup_message_set_status (msg, SOUP_STATUS_OK); return client; } /* Otherwise, it's a websocket client */ client->type = SNRA_SERVER_CLIENT_WEBSOCKET; client->need_body_complete = FALSE; client->socket = soup_client_context_get_socket (context); client->in_bufptr = client->in_buf = g_new0 (gchar, 1024); client->in_bufsize = 1024; client->in_bufavail = 0; accept_challenge = soup_message_headers_get_one (msg->request_headers, "Sec-WebSocket-Key"); accept_reply = calc_websocket_challenge_reply (accept_challenge); soup_message_headers_set_encoding (msg->response_headers, SOUP_ENCODING_EOF); soup_message_set_status (msg, SOUP_STATUS_SWITCHING_PROTOCOLS); soup_message_headers_replace (msg->response_headers, "Upgrade", "websocket"); soup_message_headers_replace (msg->response_headers, "Connection", "Upgrade"); soup_message_headers_replace (msg->response_headers, "Sec-WebSocket-Accept", accept_reply); soup_message_headers_replace (msg->response_headers, "Sec-WebSocket-Protocol", "aurena"); g_free (accept_reply); client->wrote_info_sig = g_signal_connect (msg, "wrote-informational", G_CALLBACK (snra_server_client_wrote_headers), client); return client;}
开发者ID:elisescu,项目名称:aurena,代码行数:57,
示例24: local_db_needs_update/* local_db_needs_update function returns TRUE on success and FALSE on failure. * It sets the parameter needs_update to TRUE if the local database needs * to be updated. */static gbooleanlocal_db_needs_update (SoupSession *session, const char *db_uri, GFile *db_local, gboolean *needs_update, GError **error){ GFileInfo *db_local_info; SoupMessage *msg; SoupDate *date; const gchar *db_time_str; guint64 db_time; guint64 db_local_time; guint status_code; if (g_file_query_exists (db_local, NULL) == FALSE) { *needs_update = TRUE; return TRUE; } msg = soup_message_new ("HEAD", db_uri); status_code = soup_session_send_message (session, msg); if (status_code != SOUP_STATUS_OK) { g_set_error_literal (error, SOUP_HTTP_ERROR, status_code, msg->reason_phrase); return FALSE; } db_time_str = soup_message_headers_get_one (msg->response_headers, "Last-Modified"); date = soup_date_new_from_string (db_time_str); db_time = (guint64) soup_date_to_time_t (date); soup_date_free (date); g_object_unref (msg); db_local_info = g_file_query_info (db_local, "time::modified", G_FILE_QUERY_INFO_NONE, NULL, error); if (!db_local_info) return FALSE; db_local_time = g_file_info_get_attribute_uint64 (db_local_info, "time::modified"); if (db_time <= db_local_time) *needs_update = FALSE; else *needs_update = TRUE; g_object_unref (db_local_info); return TRUE;}
开发者ID:kalev,项目名称:geoclue,代码行数:58,
示例25: soup_session_cbstatic voidsoup_session_cb (SoupSession *session, SoupMessage *msg, gpointer user_data){ DQTask *task = user_data; if (SOUP_STATUS_IS_REDIRECTION (msg->status_code)) { const char *header = soup_message_headers_get_one (msg->response_headers, "Location"); if (header) { SoupURI *uri; uri = soup_uri_new_with_base (soup_message_get_uri (msg), header); soup_message_set_uri (msg, uri); soup_uri_free (uri); soup_session_requeue_message (session, msg); return; } } else if (SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) { void *cache; task->any.callback (task->any.queue, task->any.uri, msg->response_body->data, msg->response_body->length, NULL, task->any.userdata); /* add the contents to the cache */ cache = g_memdup (msg->response_body->data, msg->response_body->length); mex_download_queue_cache_insert (task->any.queue, task->any.uri, cache, msg->response_body->length); } else if (msg->status_code != SOUP_STATUS_CANCELLED) { /* FIXME: Also create an error on failure */ task->any.callback (task->any.queue, task->any.uri, NULL, 0, NULL, task->any.userdata); } /* The message is unref'd by the session */ task->soup.message = NULL; mex_download_queue_free (task);}
开发者ID:dudochkin-victor,项目名称:mex,代码行数:54,
示例26: request_checkstatic voidrequest_check (SoupMessage *msg, gpointer user_data){ NTLMState *state = user_data; const char *header; header = soup_message_headers_get_one (msg->request_headers, "Authorization"); if (header && !strncmp (header, "NTLM " NTLM_REQUEST_START, strlen ("NTLM " NTLM_REQUEST_START))) state->sent_ntlm_request = TRUE;}
开发者ID:BabaNina,项目名称:libsoup,代码行数:12,
示例27: soap_got_headersstatic voidsoap_got_headers (SoupMessage *msg, gpointer data){ ESoapMessagePrivate *priv = E_SOAP_MESSAGE_GET_PRIVATE (msg); const gchar *size; size = soup_message_headers_get_one (msg->response_headers, "Content-Length"); if (size) priv->response_size = strtol (size, NULL, 10);}
开发者ID:tivv,项目名称:evolution-ews,代码行数:13,
示例28: server_callbackstatic voidserver_callback (SoupServer *server, SoupMessage *msg, const char *path, GHashTable *query, SoupClientContext *context, gpointer data){ const char *accept_encoding, *junk; GSList *codings; char *file = NULL, *contents; gsize length; accept_encoding = soup_message_headers_get_list (msg->request_headers, "Accept-Encoding"); if (accept_encoding) codings = soup_header_parse_quality_list (accept_encoding, NULL); else codings = NULL; if (codings && g_slist_find_custom (codings, "gzip", (GCompareFunc)g_ascii_strcasecmp)) { file = g_strdup_printf (SRCDIR "/resources%s.gz", path); if (g_file_test (file, G_FILE_TEST_EXISTS)) { soup_message_headers_append (msg->response_headers, "Content-Encoding", "gzip"); } else { g_free (file); file = NULL; } } if (!file) file = g_strdup_printf (SRCDIR "/resources%s", path); if (!g_file_get_contents (file, &contents, &length, NULL)) { /* If path.gz exists but can't be read, we'll send back * the error with "Content-Encoding: gzip" but there's * no body, so, eh. */ soup_message_set_status (msg, SOUP_STATUS_NOT_FOUND); return; } soup_message_set_status (msg, SOUP_STATUS_OK); soup_message_body_append (msg->response_body, SOUP_MEMORY_TAKE, contents, length); junk = soup_message_headers_get_one (msg->request_headers, "X-Trailing-Junk"); if (junk) { soup_message_body_append (msg->response_body, SOUP_MEMORY_COPY, junk, strlen (junk)); }}
开发者ID:ChingezKhan,项目名称:libsoup,代码行数:51,
注:本文中的soup_message_headers_get_one函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ soup_message_new函数代码示例 C++ soundlatch_w函数代码示例 |