static void copy_header (SoupURI *uri, const char *name, const char *value, gpointer dest_headers) { SoupURI *old_uri = NULL; SoupURI *new_uri = NULL; gchar *just_path = NULL; gchar *new_val = NULL; if (g_strcmp0 (name, "Location") == 0) { // convert value to URI old_uri = soup_uri_new_with_base (uri, value); // Get just the path and query just_path = soup_uri_to_string (old_uri, TRUE); // generate new uri with base plus path new_uri = soup_uri_new_with_base (uri, just_path); // convert to full url string new_val = soup_uri_to_string (new_uri, FALSE); soup_message_headers_append (dest_headers, name, new_val); g_free (new_val); g_free (just_path); soup_uri_free (old_uri); soup_uri_free (new_uri); } else { soup_message_headers_append (dest_headers, name, value); } }
void ResourceRequest::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_httpMethod = String::fromUTF8(soupMessage->method); SoupMessageHeadersIter headersIter; const char* headerName; const char* headerValue; soup_message_headers_iter_init(&headersIter, soupMessage->request_headers); while (soup_message_headers_iter_next(&headersIter, &headerName, &headerValue)) m_httpHeaderFields.set(String::fromUTF8(headerName), String::fromUTF8(headerValue)); if (soupMessage->request_body->data) m_httpBody = FormData::create(soupMessage->request_body->data, soupMessage->request_body->length); #ifdef HAVE_LIBSOUP_2_29_90 SoupURI* firstParty = soup_message_get_first_party(soupMessage); if (firstParty) { GOwnPtr<gchar> firstPartyURI(soup_uri_to_string(firstParty, FALSE)); m_firstPartyForCookies = KURL(KURL(), String::fromUTF8(firstPartyURI.get())); } #endif m_soupFlags = soup_message_get_flags(soupMessage); // FIXME: m_allowCookies should probably be handled here and on // doUpdatePlatformRequest somehow. }
// // Callback that's invoked each time that an user image has been downloaded. // // This function sets the buddy's icon based on the downloaded image, that is // assuming that the picture was successfully downloaded. // // This function always invokes a next iteration within the current worker. // static void budicons_got_image_response (SoupSession *session, SoupMessage *message, gpointer data) { PurpleBuddy *buddy = (PurpleBuddy *) data; char *url = soup_uri_to_string(soup_message_get_uri(message), FALSE); g_print("Soup: [%-3d] %s\n", message->status_code, url); g_free(url); if (! SOUP_STATUS_IS_SUCCESSFUL (message->status_code)) { return; } const char *mime = soup_message_headers_get_content_type(message->response_headers, NULL); if (g_ascii_strncasecmp(mime, "image/", strlen("image/"))) { // Wrong mime-type, this isn't an image g_print("Soup: content-type '%s' doesn't correspond to an image\n", mime); return; } // Set the icon of the buddy const char *content = message->response_body->data; gsize length = (gsize) message->response_body->length; char *icon = g_memdup(content, length); purple_buddy_icons_set_for_user( buddy->account, buddy->name, icon, length, NULL ); }
static gboolean update_progress (gpointer user_data) { OtPullData *pull_data = user_data; guint outstanding_writes = pull_data->n_outstanding_content_write_requests + pull_data->n_outstanding_metadata_write_requests; guint outstanding_fetches = pull_data->n_outstanding_content_fetches + pull_data->n_outstanding_metadata_fetches; guint64 bytes_transferred = ostree_fetcher_bytes_transferred (pull_data->fetcher); guint fetched = pull_data->n_fetched_metadata + pull_data->n_fetched_content; guint requested = pull_data->n_requested_metadata + pull_data->n_requested_content; guint n_scanned_metadata = g_atomic_int_get (&pull_data->n_scanned_metadata); g_assert (pull_data->progress); ostree_async_progress_set_uint (pull_data->progress, "outstanding-fetches", outstanding_fetches); ostree_async_progress_set_uint (pull_data->progress, "outstanding-writes", outstanding_writes); ostree_async_progress_set_uint (pull_data->progress, "fetched", fetched); ostree_async_progress_set_uint (pull_data->progress, "requested", requested); ostree_async_progress_set_uint (pull_data->progress, "scanned-metadata", n_scanned_metadata); ostree_async_progress_set_uint64 (pull_data->progress, "bytes-transferred", bytes_transferred); if (pull_data->fetching_sync_uri) { gs_free char *uri_string = soup_uri_to_string (pull_data->fetching_sync_uri, TRUE); gs_free char *status_string = g_strconcat ("Requesting %s", uri_string, NULL); ostree_async_progress_set_status (pull_data->progress, status_string); } else ostree_async_progress_set_status (pull_data->progress, NULL); return TRUE; }
/* * FIXME: make this bullet proof wrt uri scheme. */ static char * url (GSList const *args, void *user_data) { char *resolved_path; char *ret; #ifdef CCSS_WITH_SOUP char *given_path; SoupURI *uri; g_return_val_if_fail (args, NULL); given_path = g_strdup_printf ("file:///%s", (char const *) args->data); uri = soup_uri_new (given_path); g_free (given_path), given_path = NULL; resolved_path = gtk_rc_find_pixmap_in_path (gtk_settings_get_default (), NULL, uri->path); soup_uri_set_path (uri, resolved_path); g_free (resolved_path), resolved_path = NULL; ret = soup_uri_to_string (uri, false); soup_uri_free (uri), uri = NULL; #else char const *given_path; g_return_val_if_fail (args, NULL); given_path = (char const *) args->data; resolved_path = gtk_rc_find_pixmap_in_path (gtk_settings_get_default (), NULL, given_path); ret = g_strdup_printf ("file:///%s", resolved_path); g_free (resolved_path), resolved_path = NULL; #endif return ret; }
static void get_proxy_uri_async (SoupProxyURIResolver *resolver, SoupURI *uri, GMainContext *async_context, GCancellable *cancellable, SoupProxyURIResolverCallback callback, gpointer user_data) { SoupProxyResolverDefault *resolver_default = SOUP_PROXY_RESOLVER_DEFAULT (resolver); SoupProxyResolverDefaultPrivate *priv = soup_proxy_resolver_default_get_instance_private (resolver_default); SoupAsyncData *async_data; char *uri_string; async_data = g_slice_new0 (SoupAsyncData); async_data->resolver = (SoupProxyURIResolver*) g_object_ref (resolver); async_data->cancellable = cancellable; async_data->callback = callback; async_data->user_data = user_data; uri_string = soup_uri_to_string (uri, FALSE); if (async_context) g_main_context_push_thread_default (async_context); g_proxy_resolver_lookup_async (priv->gproxy_resolver, uri_string, cancellable ? g_object_ref (cancellable) : NULL, resolved_proxy, async_data); if (async_context) g_main_context_pop_thread_default (async_context); g_free (uri_string); }
static void add_image (GrlTmdbSource *self, GrlMedia *media, GrlKeyID detail_key, const char *image_path) { SoupURI *uri; GrlRelatedKeys *related_keys; char *str; int i, l; str = g_strconcat ("original", image_path, NULL); uri = soup_uri_new_with_base (self->priv->image_base_uri, str); g_free (str); str = soup_uri_to_string (uri, FALSE); l = grl_data_length (GRL_DATA (media), detail_key); for (i = 0; i < l; ++i) { related_keys = grl_data_get_related_keys (GRL_DATA (media), detail_key, i); if (g_strcmp0 (grl_related_keys_get_string (related_keys, detail_key), str) == 0) break; } if (i == l) { grl_data_add_string (GRL_DATA (media), detail_key, str); } g_free (str); soup_uri_free (uri); }
int main (int argc, char **argv) { SoupServer *server; SoupURI *uri; int ret; test_init (argc, argv, NULL); server = soup_test_server_new (SOUP_TEST_SERVER_IN_THREAD); soup_server_add_handler (server, NULL, server_callback, NULL, NULL); uri = soup_test_server_get_uri (server, "http", NULL); base_uri = soup_uri_to_string (uri, FALSE); soup_uri_free (uri); g_test_add_data_func ("/context/blocking/explicit", GINT_TO_POINTER (FALSE), do_test1); g_test_add_data_func ("/context/blocking/thread-default", GINT_TO_POINTER (TRUE), do_test1); g_test_add_data_func ("/context/nested/explicit", GINT_TO_POINTER (FALSE), do_test2); g_test_add_data_func ("/context/nested/thread-default", GINT_TO_POINTER (TRUE), do_test2); g_test_add_func ("/context/multiple", do_multicontext_test); ret = g_test_run (); g_free (base_uri); soup_test_server_quit_unref (server); test_cleanup (); return ret; }
// Called each time the message is going to be sent again except the first time. // It's used mostly to let webkit know about redirects. static void restartedCallback(SoupMessage* msg, gpointer data) { ResourceHandle* handle = static_cast<ResourceHandle*>(data); if (!handle) return; ResourceHandleInternal* d = handle->getInternal(); if (d->m_cancelled) return; char* uri = soup_uri_to_string(soup_message_get_uri(msg), false); String location = String(uri); g_free(uri); KURL newURL = KURL(handle->request().url(), location); // FIXME: This is needed because some servers use broken URIs in // their Location header, when redirecting, such as URIs with // white spaces instead of %20; this should be fixed in soup, in // the future, and this work-around removed. // See http://bugzilla.gnome.org/show_bug.cgi?id=575378. SoupURI* soup_uri = soup_uri_new(newURL.string().utf8().data()); soup_message_set_uri(msg, soup_uri); soup_uri_free(soup_uri); ResourceRequest request = handle->request(); ResourceResponse response; request.setURL(newURL); fillResponseFromMessage(msg, &response); if (d->client()) d->client()->willSendRequest(handle, request, response); }
GInputStream * uzbl_scheme_request_send (SoupRequest *request, GCancellable *cancellable, GError **error) { UZBL_UNUSED (cancellable); UZBL_UNUSED (error); UzblSchemeRequest *uzbl_request = UZBL_SCHEME_REQUEST (request); UzblSchemeRequestClass *cls = UZBL_SCHEME_REQUEST_GET_CLASS (uzbl_request); SoupURI *uri = soup_request_get_uri (request); const char *command = g_hash_table_lookup (cls->handlers, uri->scheme); GString *result = g_string_new (""); GArray *args = uzbl_commands_args_new (); const UzblCommand *cmd = uzbl_commands_parse (command, args); if (cmd) { uzbl_commands_args_append (args, soup_uri_to_string (uri, TRUE)); uzbl_commands_run_parsed (cmd, args, result); } uzbl_commands_args_free (args); gchar *end = strchr (result->str, '\n'); size_t line_len = end ? (size_t)(end - result->str) : result->len; uzbl_request->priv->content_length = result->len - line_len - 1; uzbl_request->priv->content_type = g_strndup (result->str, line_len); GInputStream *stream = g_memory_input_stream_new_from_data ( g_strdup (end + 1), uzbl_request->priv->content_length, g_free); g_string_free (result, TRUE); return stream; }
static const gchar * cal_backend_http_ensure_uri (ECalBackendHttp *backend) { ESource *source; ESourceSecurity *security_extension; ESourceWebdav *webdav_extension; SoupURI *soup_uri; gboolean secure_connection; const gchar *extension_name; gchar *uri_string; if (backend->priv->uri != NULL) return backend->priv->uri; source = e_backend_get_source (E_BACKEND (backend)); extension_name = E_SOURCE_EXTENSION_SECURITY; security_extension = e_source_get_extension (source, extension_name); extension_name = E_SOURCE_EXTENSION_WEBDAV_BACKEND; webdav_extension = e_source_get_extension (source, extension_name); secure_connection = e_source_security_get_secure (security_extension); soup_uri = e_source_webdav_dup_soup_uri (webdav_extension); uri_string = soup_uri_to_string (soup_uri, FALSE); soup_uri_free (soup_uri); backend->priv->uri = webcal_to_http_method ( uri_string, secure_connection); g_free (uri_string); return backend->priv->uri; }
static void http_post_handler (SoupMessage *msg, const gchar *path, DBusClient *dbus_client) { gchar *data; gchar *new_path; new_path = g_strdup (path + strlen ("/")); if (msg->method == SOUP_METHOD_POST) data = g_strdup (msg->request_body->data); else { gchar *tmp; tmp = soup_uri_to_string (soup_message_get_uri (msg), TRUE); data = g_strdup (tmp + strlen ("/?") + strlen (new_path)); g_free (tmp); } g_debug ("got post %s", path + strlen ("/")); soup_message_headers_foreach (msg->request_headers, headers_ispct, NULL); g_debug ("data: %s", data); dbus_client_call (dbus_client, path + strlen ("/"), data); g_free (data); g_free (new_path); http_post_send_response (msg); }
int main(int argc, char** argv) { SoupServer* server; SoupURI* soup_uri; g_thread_init(NULL); gtk_test_init(&argc, &argv, NULL); /* Hopefully make test independent of the path it's called from. */ testutils_relative_chdir("WebKit/gtk/tests/resources/test.html", argv[0]); server = soup_server_new(SOUP_SERVER_PORT, 0, NULL); soup_server_run_async(server); soup_server_add_handler(server, NULL, server_callback, NULL, NULL); soup_uri = soup_uri_new("http://127.0.0.1/"); soup_uri_set_port(soup_uri, soup_server_get_port(server)); base_uri = soup_uri_to_string(soup_uri, FALSE); soup_uri_free(soup_uri); g_test_bug_base("https://bugs.webkit.org/"); g_test_add_func("/webkit/webview/icon-uri", test_webkit_web_view_icon_uri); g_test_add_func("/webkit/webview/adjustments", test_webkit_web_view_adjustments); g_test_add_func("/webkit/webview/destroy", test_webkit_web_view_destroy); g_test_add_func("/webkit/webview/grab_focus", test_webkit_web_view_grab_focus); g_test_add_func("/webkit/webview/window-features", test_webkit_web_view_window_features); return g_test_run (); }
static gboolean soup_request_initable_init (GInitable *initable, GCancellable *cancellable, GError **error) { SoupRequest *request = SOUP_REQUEST (initable); gboolean ok; if (!request->priv->uri) { g_set_error (error, SOUP_REQUEST_ERROR, SOUP_REQUEST_ERROR_BAD_URI, _("No URI provided")); return FALSE; } ok = SOUP_REQUEST_GET_CLASS (initable)-> check_uri (request, request->priv->uri, error); if (!ok && error && !*error) { char *uri_string = soup_uri_to_string (request->priv->uri, FALSE); g_set_error (error, SOUP_REQUEST_ERROR, SOUP_REQUEST_ERROR_BAD_URI, _("Invalid '%s' URI: %s"), request->priv->uri->scheme, uri_string); g_free (uri_string); } return ok; }
char * flickr_proxy_build_login_url (FlickrProxy *proxy, const char *frob, const char *perms) { SoupURI *uri; GHashTable *params; char *sig, *s; g_return_val_if_fail (FLICKR_IS_PROXY (proxy), NULL); uri = soup_uri_new ("http://flickr.com/services/auth/"); params = g_hash_table_new (g_str_hash, g_str_equal); g_hash_table_insert (params, "api_key", proxy->priv->api_key); g_hash_table_insert (params, "perms", (gpointer)perms); if (frob) g_hash_table_insert (params, "frob", (gpointer)frob); sig = flickr_proxy_sign (proxy, params); g_hash_table_insert (params, "api_sig", sig); soup_uri_set_query_from_form (uri, params); s = soup_uri_to_string (uri, FALSE); g_free (sig); g_hash_table_destroy (params); soup_uri_free (uri); return s; }
void 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"))); }
/** * Change scheme and port of soup messages uri if the host is a known and * valid hsts host. * * This logic should be implemented in request_queued function but the changes * that are done there to the uri do not appear in webkit_web_view_get_uri(). * If a valid hsts host is requested via http and the url is changed to https * vimb would still show the http uri in url bar. This seems to be a * missbehaviour in webkit, but for now we provide this function to put in the * logic in the scope of the navigation-policy-decision-requested event of the * webview. * * Returns newly allocated string with new URI if the URI was change to * fullfill HSTS, else NULL. */ char *hsts_get_changed_uri(SoupSession* session, SoupMessage *msg) { SoupSessionFeature *feature; HSTSProvider *provider; SoupURI *uri; if (!msg) { return NULL; } feature = soup_session_get_feature_for_message(session, HSTS_TYPE_PROVIDER, msg); uri = soup_message_get_uri(msg); if (!feature || !uri) { return NULL; } provider = HSTS_PROVIDER(feature); /* if URI uses still https we don't nee to rewrite it */ if (uri->scheme != SOUP_URI_SCHEME_HTTPS && should_secure_host(provider, uri->host) ) { /* the ports is set by soup uri if scheme is changed */ soup_uri_set_scheme(uri, SOUP_URI_SCHEME_HTTPS); return soup_uri_to_string(uri, false); } return NULL; }
CString WebKitTestServer::getURIForPath(const char* path) { SoupURI* uri = soup_uri_new_with_base(m_baseURI, path); GUniquePtr<gchar> uriString(soup_uri_to_string(uri, FALSE)); soup_uri_free(uri); return uriString.get(); }
int main(int argc, char** argv) { SoupServer* server; SoupURI* soup_uri; gtk_test_init(&argc, &argv, NULL); /* Hopefully make test independent of the path it's called from. */ testutils_relative_chdir("Source/WebKit/gtk/tests/resources/test.html", argv[0]); server = soup_server_new(SOUP_SERVER_PORT, 0, NULL); soup_server_run_async(server); soup_server_add_handler(server, NULL, server_callback, NULL, NULL); soup_uri = soup_uri_new("http://127.0.0.1/"); soup_uri_set_port(soup_uri, soup_server_get_port(server)); base_uri = soup_uri_to_string(soup_uri, FALSE); soup_uri_free(soup_uri); g_test_bug_base("https://bugs.webkit.org/"); g_test_add_func("/webkit/webview/icon-uri", test_webkit_web_view_icon_uri); g_test_add_func("/webkit/webview/adjustments", test_webkit_web_view_adjustments); g_test_add_func("/webkit/webview/destroy", test_webkit_web_view_destroy); g_test_add_func("/webkit/webview/grab_focus", test_webkit_web_view_grab_focus); g_test_add_func("/webkit/webview/window-features", test_webkit_web_view_window_features); g_test_add_func("/webkit/webview/webview-in-offscreen-window-does-not-crash", test_webkit_web_view_in_offscreen_window_does_not_crash); g_test_add_func("/webkit/webview/webview-does-not-steal-focus", test_webkit_web_view_does_not_steal_focus); g_test_add_data_func("/webkit/webview/fullscreen", GINT_TO_POINTER(FALSE), test_webkit_web_view_fullscreen); g_test_add_data_func("/webkit/webview/fullscreen-blocked", GINT_TO_POINTER(TRUE), test_webkit_web_view_fullscreen); g_test_add_func("/webkit/webview/file-chooser", test_webkit_web_view_file_chooser); return g_test_run (); }
static void test_network_request_properties() { WebKitNetworkRequest* request; SoupMessage* message; gchar* soupURI; /* Test URI is set correctly when creating with URI */ request = webkit_network_request_new("http://debian.org/"); g_assert(WEBKIT_IS_NETWORK_REQUEST(request)); g_assert_cmpstr(webkit_network_request_get_uri(request), ==, "http://debian.org/"); g_object_unref(request); /* Test URI is set correctly when creating with Message */ message = soup_message_new("GET", "http://debian.org/"); request = WEBKIT_NETWORK_REQUEST(g_object_new(WEBKIT_TYPE_NETWORK_REQUEST, "message", message, NULL)); g_assert(WEBKIT_IS_NETWORK_REQUEST(request)); g_object_unref(message); message = webkit_network_request_get_message(request); soupURI = soup_uri_to_string(soup_message_get_uri(message), FALSE); g_assert_cmpstr(soupURI, ==, "http://debian.org/"); g_free(soupURI); g_assert_cmpstr(webkit_network_request_get_uri(request), ==, "http://debian.org/"); g_object_unref(request); }
int main(int argc, char **argv) { gtk_test_init(&argc, &argv, NULL); /* This hopefully makes the test independent of the path it's called from. */ testutils_relative_chdir("Source/WebKit/gtk/tests/resources/test.html", argv[0]); SoupServer *server = soup_server_new(SOUP_SERVER_PORT, 0, NULL); soup_server_run_async(server); soup_server_add_handler(server, NULL, serverCallback, NULL, NULL); SoupURI *soupURI = soup_uri_new("http://127.0.0.1/"); soup_uri_set_port(soupURI, soup_server_get_port(server)); baseURI = soup_uri_to_string(soupURI, FALSE); soup_uri_free(soupURI); g_test_bug_base("https://bugs.webkit.org/"); g_test_add_func("/webkit/favicondatabase/set-path", testWebKitFaviconDatabaseSetPath); // These two tests will trigger an ASSERTION on debug builds due // to http://webkit.org/b/67582. Remove the guards once the bug is fixed. #ifdef NDEBUG g_test_add_func("/webkit/favicondatabase/get-favicon", testWebKitFaviconDatabaseGetFavicon); g_test_add_func("/webkit/favicondatabase/get-favicon-uri", testWebKitFaviconDatabaseGetFaviconURI); #endif g_test_add_func("/webkit/favicondatabase/remove-all", testWebKitFaviconDatabaseRemoveAll); g_test_add_func("/webkit/favicondatabase/close-db", testWebKitFaviconDatabaseCloseDatabase); return g_test_run(); }
static gint luaH_webview_get_prop(lua_State *L) { widget_t *w = luaH_checkudata(L, 1, &widget_class); const gchar *prop = luaL_checkstring(L, 2); GtkWidget *view = GTK_WIDGET(g_object_get_data(G_OBJECT(w->widget), "webview")); GObject *ws; property_tmp_values tmp; SoupURI *u; for (guint i = 0; i < LENGTH(properties); i++) { if (g_strcmp0(properties[i].name, prop)) continue; ws = get_settings_object(view, properties[i].scope); switch(properties[i].type) { case BOOL: g_object_get(ws, prop, &tmp.b, NULL); lua_pushboolean(L, tmp.b); return 1; case CHAR: g_object_get(ws, prop, &tmp.c, NULL); lua_pushstring(L, tmp.c); g_free(tmp.c); return 1; case INT: g_object_get(ws, prop, &tmp.i, NULL); lua_pushnumber(L, tmp.i); return 1; case FLOAT: g_object_get(ws, prop, &tmp.f, NULL); lua_pushnumber(L, tmp.f); return 1; case DOUBLE: g_object_get(ws, prop, &tmp.d, NULL); lua_pushnumber(L, tmp.d); return 1; case URI: g_object_get(ws, prop, &u, NULL); tmp.c = soup_uri_to_string(u, 0); lua_pushstring(L, tmp.c); soup_uri_free(u); g_free(tmp.c); return 1; default: warn("unknown property type for: %s", properties[i].name); break; } } warn("unknown property: %s", prop); return 0; }
/** * fwupd_remote_build_firmware_uri: * @self: A #FwupdRemote * @url: the URL to use * @error: the #GError, or %NULL * * Builds a URI for the URL using the username and password set for the remote, * including any basename URI substitution. * * Returns: (transfer full): a URI, or %NULL for error * * Since: 0.9.7 **/ gchar * fwupd_remote_build_firmware_uri (FwupdRemote *self, const gchar *url, GError **error) { g_autoptr(SoupURI) uri = fwupd_remote_build_uri (self, url, error); if (uri == NULL) return NULL; return soup_uri_to_string (uri, FALSE); }
static void do_get (SoupMessage * msg, const char *path) { char *uri; int buflen = 4096; SoupKnownStatusCode status = SOUP_STATUS_OK; uri = soup_uri_to_string (soup_message_get_uri (msg), FALSE); GST_DEBUG ("request: \"%s\"", uri); if (!strcmp (path, "/301")) status = SOUP_STATUS_MOVED_PERMANENTLY; else if (!strcmp (path, "/302")) status = SOUP_STATUS_MOVED_TEMPORARILY; else if (!strcmp (path, "/307")) status = SOUP_STATUS_TEMPORARY_REDIRECT; else if (!strcmp (path, "/403")) status = SOUP_STATUS_FORBIDDEN; else if (!strcmp (path, "/404")) status = SOUP_STATUS_NOT_FOUND; if (SOUP_STATUS_IS_REDIRECTION (status)) { char *redir_uri; redir_uri = g_strdup_printf ("%s-redirected", uri); soup_message_headers_append (msg->response_headers, "Location", redir_uri); g_free (redir_uri); } if (status != SOUP_STATUS_OK) goto leave; if (msg->method == SOUP_METHOD_GET) { char *buf; buf = g_malloc (buflen); memset (buf, 0, buflen); soup_message_body_append (msg->response_body, SOUP_MEMORY_TAKE, buf, buflen); } else { /* msg->method == SOUP_METHOD_HEAD */ char *length; /* We could just use the same code for both GET and * HEAD. But we'll optimize and avoid the extra * malloc. */ length = g_strdup_printf ("%lu", (gulong) buflen); soup_message_headers_append (msg->response_headers, "Content-Length", length); g_free (length); } leave: soup_message_set_status (msg, status); g_free (uri); }
void show_device_details (GUPnPDeviceInfo *info) { char *details[32]; const SoupURI *uri; const char *str; int i = 0; details[i++] = _("Location"); str = gupnp_device_info_get_location (info); if (str) details[i++] = g_strdup (str); details[i++] = _("UDN"); str = gupnp_device_info_get_udn (info); if (str) details[i++] = g_strdup (str); details[i++] = _("Type"); str = gupnp_device_info_get_device_type (info); if (str) details[i++] = g_strdup (str); details[i++] = _("Base URL"); uri = gupnp_device_info_get_url_base (info); if (uri) details[i++] = soup_uri_to_string ((SoupURI *) uri, FALSE); details[i++] = _("Friendly Name"); details[i++] = gupnp_device_info_get_friendly_name (info); details[i++] = _("Manufacturer"); details[i++] = gupnp_device_info_get_manufacturer (info); details[i++] = _("Manufacturer URL"); details[i++] = gupnp_device_info_get_manufacturer_url (info); details[i++] = _("Model Description"); details[i++] = gupnp_device_info_get_model_description (info); details[i++] = _("Model Name"); details[i++] = gupnp_device_info_get_model_name (info); details[i++] = _("Model Number"); details[i++] = gupnp_device_info_get_model_number (info); details[i++] = _("Model URL"); details[i++] = gupnp_device_info_get_model_url (info); details[i++] = _("Serial Number"); details[i++] = gupnp_device_info_get_serial_number (info); details[i++] = _("UPC"); details[i++] = gupnp_device_info_get_upc (info); details[i++] = _("Presentation URL"); details[i++] = gupnp_device_info_get_presentation_url (info); details[i] = NULL; update_details ((const char **) details); /* Only free the values */ for (i = 1; details[i - 1]; i += 2) { if (details[i]) g_free (details[i]); } }
void gst_soup_http_client_sink_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) { GstSoupHttpClientSink *souphttpsink = GST_SOUP_HTTP_CLIENT_SINK (object); switch (property_id) { case PROP_SESSION: g_value_set_object (value, souphttpsink->prop_session); break; case PROP_LOCATION: g_value_set_string (value, souphttpsink->location); break; case PROP_AUTOMATIC_REDIRECT: g_value_set_boolean (value, souphttpsink->automatic_redirect); break; case PROP_USER_AGENT: g_value_set_string (value, souphttpsink->user_agent); break; case PROP_USER_ID: g_value_set_string (value, souphttpsink->user_id); break; case PROP_USER_PW: g_value_set_string (value, souphttpsink->user_pw); break; case PROP_PROXY_ID: g_value_set_string (value, souphttpsink->proxy_id); break; case PROP_PROXY_PW: g_value_set_string (value, souphttpsink->proxy_pw); break; case PROP_PROXY: if (souphttpsink->proxy == NULL) g_value_set_static_string (value, ""); else { char *proxy = soup_uri_to_string (souphttpsink->proxy, FALSE); g_value_set_string (value, proxy); g_free (proxy); } break; case PROP_COOKIES: g_value_set_boxed (value, g_strdupv (souphttpsink->cookies)); break; case PROP_SOUP_LOG_LEVEL: g_value_set_enum (value, souphttpsink->log_level); break; case PROP_RETRY_DELAY: g_value_set_int (value, souphttpsink->retry_delay); break; case PROP_RETRIES: g_value_set_int (value, souphttpsink->retries); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } }
void HTTPClientReceiver::message_callback(SoupSession* session, SoupMessage* msg, void* ptr) { if (ptr == NULL) return; HTTPClientReceiver* me = (HTTPClientReceiver*)ptr; const string path = soup_message_get_uri(msg)->path; if (msg->response_body->data == NULL) { LOG(error) << "Empty client message" << endl; return; } if (path == "/") { me->_target->response_ok(0); } else if (path == "/plugins") { if (msg->response_body->data == NULL) { LOG(error) << "Empty response" << endl; } else { Glib::Mutex::Lock lock(me->_mutex); me->_target->response_ok(0); me->_world->parser()->parse_string(me->_world, me->_target.get(), Glib::ustring(msg->response_body->data), me->_url); } } else if (path.substr(0, 6) == "/patch") { if (msg->response_body->data == NULL) { LOG(error) << "Empty response" << endl; } else { Glib::Mutex::Lock lock(me->_mutex); me->_target->response_ok(0); me->_world->parser()->parse_string( me->_world, me->_target.get(), Glib::ustring(msg->response_body->data), path); } } else if (path == "/stream") { if (msg->response_body->data == NULL) { LOG(error) << "Empty response" << endl; } else { Glib::Mutex::Lock lock(me->_mutex); string uri = string(soup_uri_to_string(soup_message_get_uri(msg), false)); uri = uri.substr(0, uri.find_last_of(":")); uri += string(":") + msg->response_body->data; LOG(info) << "Stream URI: " << uri << endl; me->_listener = boost::shared_ptr<Listener>(new Listener(me, uri)); me->_listener->start(); } } else { LOG(error) << "Unknown message: " << path << endl; me->update(msg->response_body->data); } }
JNIEXPORT jintLong JNICALL WebKitGTK_NATIVE(_1soup_1uri_1to_1string) (JNIEnv *env, jclass that, jintLong arg0, jint arg1) { jintLong rc = 0; WebKitGTK_NATIVE_ENTER(env, that, _1soup_1uri_1to_1string_FUNC); rc = (jintLong)soup_uri_to_string((SoupURI *)arg0, arg1); WebKitGTK_NATIVE_EXIT(env, that, _1soup_1uri_1to_1string_FUNC); return rc; }
static char * sign_hmac (OAuthProxy *proxy, RestProxyCall *call, GHashTable *oauth_params) { OAuthProxyPrivate *priv; RestProxyCallPrivate *callpriv; char *key, *signature, *ep, *eep; GString *text; GHashTable *all_params; priv = PROXY_GET_PRIVATE (proxy); callpriv = call->priv; text = g_string_new (NULL); g_string_append (text, rest_proxy_call_get_method (REST_PROXY_CALL (call))); g_string_append_c (text, '&'); if (priv->oauth_echo) { g_string_append_uri_escaped (text, priv->service_url, NULL, FALSE); } else if (priv->signature_host != NULL) { SoupURI *url = soup_uri_new (callpriv->url); gchar *signing_url; soup_uri_set_host (url, priv->signature_host); signing_url = soup_uri_to_string (url, FALSE); g_string_append_uri_escaped (text, signing_url, NULL, FALSE); soup_uri_free (url); g_free (signing_url); } else { g_string_append_uri_escaped (text, callpriv->url, NULL, FALSE); } g_string_append_c (text, '&'); /* Merge the OAuth parameters with the query parameters */ all_params = g_hash_table_new (g_str_hash, g_str_equal); merge_hashes (all_params, oauth_params); if (!priv->oauth_echo) merge_params (all_params, callpriv->params); ep = encode_params (all_params); eep = OAUTH_ENCODE_STRING (ep); g_string_append (text, eep); g_free (ep); g_free (eep); g_hash_table_destroy (all_params); /* PLAINTEXT signature value is the HMAC-SHA1 key value */ key = sign_plaintext (priv); signature = hmac_sha1 (key, text->str); g_free (key); g_string_free (text, TRUE); return signature; }
static void request_finished_cb (SoupMessage *message, gpointer data) { SoupURI *uri; char *uri_string; uri = soup_message_get_uri(message); uri_string = soup_uri_to_string(uri, FALSE); printf("Finished download of %s\n", uri_string); g_free(uri_string); }