[libsoup/wip/soup-uri-removal: 18/19] Privitize most URI functions and document the public ones




commit 7a25a71fe2bf8d2eae30c78d4429cfcb669e38f2
Author: Patrick Griffis <pgriffis igalia com>
Date:   Sun Oct 25 13:30:09 2020 -0500

    Privitize most URI functions and document the public ones

 docs/reference/libsoup-3.0-docs.xml           |  2 +-
 docs/reference/libsoup-3.0-sections.txt       |  9 ++++
 libsoup/auth/soup-auth-negotiate.c            |  2 +-
 libsoup/include/soup-installed.h              |  2 +-
 libsoup/meson.build                           |  4 +-
 libsoup/server/soup-server.h                  |  2 +-
 libsoup/soup-uri-utils-private.h              | 36 ++++++++++++++++
 libsoup/{soup-uri.c => soup-uri-utils.c}      | 22 ++++++++--
 libsoup/soup-uri-utils.h                      | 39 +++++++++++++++++
 libsoup/soup-uri.h                            | 60 ---------------------------
 libsoup/soup.h                                |  3 +-
 libsoup/websocket/soup-websocket-connection.c |  2 +-
 12 files changed, 112 insertions(+), 71 deletions(-)
---
diff --git a/docs/reference/libsoup-3.0-docs.xml b/docs/reference/libsoup-3.0-docs.xml
index 97779882..e2c51618 100644
--- a/docs/reference/libsoup-3.0-docs.xml
+++ b/docs/reference/libsoup-3.0-docs.xml
@@ -29,7 +29,6 @@
     <xi:include href="xml/soup-multipart-input-stream.xml"/>
     <xi:include href="xml/soup-session.xml"/>
     <xi:include href="xml/soup-status.xml"/>
-    <xi:include href="xml/soup-uri.xml"/>
   </chapter>
 
   <chapter>
@@ -84,6 +83,7 @@
     <title>Utility API</title>
     <xi:include href="xml/soup-date-utils.xml"/>
     <xi:include href="xml/soup-tld.xml"/>
+    <xi:include href="xml/soup-uri-utils.xml"/>
     <xi:include href="xml/soup-version.xml"/>
   </chapter>
 
diff --git a/docs/reference/libsoup-3.0-sections.txt b/docs/reference/libsoup-3.0-sections.txt
index c0256675..2a7c4763 100644
--- a/docs/reference/libsoup-3.0-sections.txt
+++ b/docs/reference/libsoup-3.0-sections.txt
@@ -582,6 +582,15 @@ soup_date_time_to_string
 soup_date_time_is_past
 </SECTION>
 
+<SECTION>
+<FILE>soup-uri-utils</FILE>
+soup_uri_equal
+soup_uri_copy_with_query_from_form
+soup_uri_copy_with_query_from_fields
+soup_uri_get_port_with_default
+SOUP_HTTP_URI_FLAGS
+</SECTION>
+
 <SECTION>
 <FILE>soup-form</FILE>
 <TITLE>SoupForm</TITLE>
diff --git a/libsoup/auth/soup-auth-negotiate.c b/libsoup/auth/soup-auth-negotiate.c
index 916337f2..84cbb0f1 100644
--- a/libsoup/auth/soup-auth-negotiate.c
+++ b/libsoup/auth/soup-auth-negotiate.c
@@ -21,7 +21,7 @@
 #include "soup-message.h"
 #include "soup-message-private.h"
 #include "soup-misc.h"
-#include "soup-uri.h"
+#include "soup-uri-utils-private.h"
 
 /**
  * soup_auth_negotiate_supported:
diff --git a/libsoup/include/soup-installed.h b/libsoup/include/soup-installed.h
index 1abe966e..aa522c41 100644
--- a/libsoup/include/soup-installed.h
+++ b/libsoup/include/soup-installed.h
@@ -48,7 +48,7 @@ extern "C" {
 #include <libsoup/soup-session-feature.h>
 #include <libsoup/soup-status.h>
 #include <libsoup/soup-tld.h>
-#include <libsoup/soup-uri.h>
+#include <libsoup/soup-uri-utils.h>
 #include <libsoup/soup-version.h>
 #include <libsoup/soup-websocket.h>
 #include <libsoup/soup-websocket-connection.h>
diff --git a/libsoup/meson.build b/libsoup/meson.build
index e8bf6f43..6b8e6cfa 100644
--- a/libsoup/meson.build
+++ b/libsoup/meson.build
@@ -80,7 +80,7 @@ soup_sources = [
   'soup-socket-properties.c',
   'soup-status.c',
   'soup-tld.c',
-  'soup-uri.c',
+  'soup-uri-utils.c',
   'soup-version.c',
 ]
 
@@ -138,7 +138,7 @@ soup_introspection_headers = [
   'soup-status.h',
   'soup-tld.h',
   'soup-types.h',
-  'soup-uri.h',
+  'soup-uri-utils.h',
 ]
 
 soup_installed_headers = soup_introspection_headers
diff --git a/libsoup/server/soup-server.h b/libsoup/server/soup-server.h
index b5225207..8a8d53d0 100644
--- a/libsoup/server/soup-server.h
+++ b/libsoup/server/soup-server.h
@@ -6,7 +6,7 @@
 #pragma once
 
 #include "soup-types.h"
-#include "soup-uri.h"
+#include "soup-uri-utils.h"
 #include "soup-websocket-connection.h"
 
 G_BEGIN_DECLS
diff --git a/libsoup/soup-uri-utils-private.h b/libsoup/soup-uri-utils-private.h
new file mode 100644
index 00000000..526ba0ee
--- /dev/null
+++ b/libsoup/soup-uri-utils-private.h
@@ -0,0 +1,36 @@
+/* 
+ * Copyright 1999-2002 Ximian, Inc.
+ * Copyright 2020 Igalia, S.L.
+ */
+
+
+#pragma once
+
+#include "soup-uri-utils.h"
+
+G_BEGIN_DECLS
+
+gboolean     soup_uri_is_http               (GUri       *uri,
+                                             char      **aliases);
+
+gboolean     soup_uri_is_https              (GUri       *uri,
+                                             char      **aliases);
+
+gboolean     soup_uri_uses_default_port     (GUri       *uri);
+
+GUri        *soup_uri_copy_with_credentials (GUri       *uri,
+                                             const char *username,
+                                             const char *password);
+
+char        *soup_uri_get_path_and_query    (GUri       *uri);
+
+GUri        *soup_uri_copy_host             (GUri       *uri);
+
+gboolean     soup_uri_valid_for_http        (GUri       *uri,
+                                             GError    **error);
+
+guint        soup_uri_host_hash             (gconstpointer key);
+
+gboolean     soup_uri_host_equal            (gconstpointer v1, gconstpointer v2);
+
+G_END_DECLS
diff --git a/libsoup/soup-uri.c b/libsoup/soup-uri-utils.c
similarity index 95%
rename from libsoup/soup-uri.c
rename to libsoup/soup-uri-utils.c
index 9bab2a4d..e826a7a0 100644
--- a/libsoup/soup-uri.c
+++ b/libsoup/soup-uri-utils.c
@@ -12,10 +12,17 @@
 #include <string.h>
 #include <stdlib.h>
 
-#include "soup-uri.h"
+#include "soup-uri-utils.h"
 #include "soup.h"
 #include "soup-misc.h"
 
+/**
+ * SECTION:soup-uri-utils
+ * @section_id: SoupURIUtils
+ * @title: URI Utilities
+ * @short_description: Functions to help working with #GUri and HTTP
+ */
+
 static inline int
 soup_scheme_default_port (const char *scheme)
 {
@@ -52,6 +59,15 @@ path_equal (const char *one, const char *two)
        return !strcmp (one, two);
 }
 
+/**
+ * soup_uri_get_port_with_default:
+ * @uri: A #GUri
+ *
+ * If @uri has a port of `-1` this will return the default
+ * port for the sheme it uses if known.
+ *
+ * Returns: The port to use with the @uri or `-1` if unknown.
+ */
 int
 soup_uri_get_port_with_default (GUri *uri)
 {
@@ -335,7 +351,7 @@ soup_uri_is_http (GUri *uri, char **aliases)
 #define BASE64_INDICATOR_LEN (sizeof (";base64") - 1)
 
 /**
- * soup_uri_decode_data:
+ * soup_uri_decode_data_uri:
  * @uri: a data URI, in string form
  * @content_type: (out) (nullable) (transfer full): location to store content type, or %NULL
  *
@@ -433,7 +449,7 @@ soup_uri_valid_for_http (GUri *uri, GError **error)
         if (!(flags & (G_URI_FLAGS_ENCODED_PATH | G_URI_FLAGS_ENCODED_QUERY | G_URI_FLAGS_ENCODED_FRAGMENT) 
||
               flags & G_URI_FLAGS_ENCODED) ||
             !(flags & G_URI_FLAGS_SCHEME_NORMALIZE)) {
-                g_set_error_literal (error, SOUP_REQUEST_ERROR, SOUP_REQUEST_ERROR_BAD_URI, "URI does not 
have encoded flags set");
+                g_set_error_literal (error, SOUP_SESSION_ERROR, SOUP_SESSION_ERROR_BAD_URI, "URI does not 
have encoded flags set");
                 return FALSE;
         }
 
diff --git a/libsoup/soup-uri-utils.h b/libsoup/soup-uri-utils.h
new file mode 100644
index 00000000..42eea4f2
--- /dev/null
+++ b/libsoup/soup-uri-utils.h
@@ -0,0 +1,39 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/* 
+ * Copyright 1999-2002 Ximian, Inc.
+ */
+
+
+#pragma once
+
+#include "soup-types.h"
+
+G_BEGIN_DECLS
+
+SOUP_AVAILABLE_IN_ALL
+GBytes     *soup_uri_decode_data_uri       (const char *uri,
+                                           char      **content_type);
+
+SOUP_AVAILABLE_IN_ALL
+gboolean soup_uri_equal (GUri *uri1, GUri *uri2);
+
+SOUP_AVAILABLE_IN_ALL
+GUri       *soup_uri_copy_with_query_from_form   (GUri       *uri,
+                                                  GHashTable *form);
+
+SOUP_AVAILABLE_IN_ALL
+GUri       *soup_uri_copy_with_query_from_fields (GUri       *uri,
+                                                  const char *first_field,
+                                                  ...) G_GNUC_NULL_TERMINATED;
+
+SOUP_AVAILABLE_IN_ALL
+int          soup_uri_get_port_with_default      (GUri       *uri);
+
+/**
+ * SOUP_HTTP_URI_FLAGS:
+ * The set of #GUriFlags libsoup expects all #GUri to use.
+ */
+#define SOUP_HTTP_URI_FLAGS (G_URI_FLAGS_HAS_PASSWORD | G_URI_FLAGS_ENCODED_PATH | G_URI_FLAGS_ENCODED_QUERY 
| G_URI_FLAGS_ENCODED_FRAGMENT | G_URI_FLAGS_SCHEME_NORMALIZE)
+
+G_END_DECLS
diff --git a/libsoup/soup.h b/libsoup/soup.h
index c2b6c60b..7d3c9b90 100644
--- a/libsoup/soup.h
+++ b/libsoup/soup.h
@@ -47,7 +47,8 @@ extern "C" {
 #include "soup-socket.h"
 #include "soup-status.h"
 #include "soup-tld.h"
-#include "soup-uri.h"
+#include "soup-uri-utils.h"
+#include "soup-uri-utils-private.h"
 #include "soup-version.h"
 #include "websocket/soup-websocket.h"
 #include "websocket/soup-websocket-connection.h"
diff --git a/libsoup/websocket/soup-websocket-connection.c b/libsoup/websocket/soup-websocket-connection.c
index 6c85c8f9..6bfbeddd 100644
--- a/libsoup/websocket/soup-websocket-connection.c
+++ b/libsoup/websocket/soup-websocket-connection.c
@@ -25,7 +25,7 @@
 #include "soup-websocket-connection.h"
 #include "soup-enum-types.h"
 #include "soup-io-stream.h"
-#include "soup-uri.h"
+#include "soup-uri-utils.h"
 #include "soup-websocket-extension.h"
 
 /*


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]