[libsoup/websocket: 8/11] uri: add support for WebSocket schemes



commit 804538f771ec2cc3bbd704c91fbc1f41bfb15e6c
Author: Lionel Landwerlin <llandwerlin gmail com>
Date:   Mon Jan 20 13:41:02 2014 +0000

    uri: add support for WebSocket schemes

 docs/reference/libsoup-2.4-sections.txt |    2 ++
 libsoup/libsoup-2.4.sym                 |    2 ++
 libsoup/soup-uri.c                      |    9 +++++++--
 libsoup/soup-uri.h                      |    3 +++
 4 files changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/docs/reference/libsoup-2.4-sections.txt b/docs/reference/libsoup-2.4-sections.txt
index b40bf7b..239f1eb 100644
--- a/docs/reference/libsoup-2.4-sections.txt
+++ b/docs/reference/libsoup-2.4-sections.txt
@@ -704,6 +704,8 @@ SOUP_URI_SCHEME_DATA
 SOUP_URI_SCHEME_FILE
 SOUP_URI_SCHEME_FTP
 SOUP_URI_SCHEME_RESOURCE
+SOUP_URI_SCHEME_WS
+SOUP_URI_SCHEME_WSS
 soup_uri_uses_default_port
 SOUP_URI_IS_VALID
 SOUP_URI_VALID_FOR_HTTP
diff --git a/libsoup/libsoup-2.4.sym b/libsoup/libsoup-2.4.sym
index 5596b4f..08892f8 100644
--- a/libsoup/libsoup-2.4.sym
+++ b/libsoup/libsoup-2.4.sym
@@ -19,6 +19,8 @@ _SOUP_URI_SCHEME_FTP
 _SOUP_URI_SCHEME_HTTP
 _SOUP_URI_SCHEME_HTTPS
 _SOUP_URI_SCHEME_RESOURCE
+_SOUP_URI_SCHEME_WS
+_SOUP_URI_SCHEME_WSS
 soup_add_completion
 soup_add_idle
 soup_add_io_watch
diff --git a/libsoup/soup-uri.c b/libsoup/soup-uri.c
index fcd7d53..e3e0dbc 100644
--- a/libsoup/soup-uri.c
+++ b/libsoup/soup-uri.c
@@ -160,6 +160,7 @@ static void append_uri_encoded (GString *str, const char *in, const char *extra_
 static char *uri_normalized_copy (const char *str, int length, const char *unescape_extra);
 
 gpointer _SOUP_URI_SCHEME_HTTP, _SOUP_URI_SCHEME_HTTPS;
+gpointer _SOUP_URI_SCHEME_WS, _SOUP_URI_SCHEME_WSS;
 gpointer _SOUP_URI_SCHEME_FTP;
 gpointer _SOUP_URI_SCHEME_FILE, _SOUP_URI_SCHEME_DATA, _SOUP_URI_SCHEME_RESOURCE;
 
@@ -172,6 +173,10 @@ soup_uri_parse_scheme (const char *scheme, int len)
                return SOUP_URI_SCHEME_HTTPS;
        } else if (len == 8 && !g_ascii_strncasecmp (scheme, "resource", len)) {
                return SOUP_URI_SCHEME_RESOURCE;
+       } else if (len == 2 && !g_ascii_strncasecmp (scheme, "ws", len)) {
+               return SOUP_URI_SCHEME_WS;
+       } else if (len == 3 && !g_ascii_strncasecmp (scheme, "wss", len)) {
+               return SOUP_URI_SCHEME_WSS;
        } else {
                char *lower_scheme;
 
@@ -186,9 +191,9 @@ soup_uri_parse_scheme (const char *scheme, int len)
 static inline guint
 soup_scheme_default_port (const char *scheme)
 {
-       if (scheme == SOUP_URI_SCHEME_HTTP)
+       if (scheme == SOUP_URI_SCHEME_HTTP || scheme == SOUP_URI_SCHEME_WS)
                return 80;
-       else if (scheme == SOUP_URI_SCHEME_HTTPS)
+       else if (scheme == SOUP_URI_SCHEME_HTTPS || scheme == SOUP_URI_SCHEME_WSS)
                return 443;
        else if (scheme == SOUP_URI_SCHEME_FTP)
                return 21;
diff --git a/libsoup/soup-uri.h b/libsoup/soup-uri.h
index fca97f7..35e670c 100644
--- a/libsoup/soup-uri.h
+++ b/libsoup/soup-uri.h
@@ -37,9 +37,12 @@ GType       soup_uri_get_type              (void);
 #define SOUP_URI_SCHEME_FILE     _SOUP_ATOMIC_INTERN_STRING (_SOUP_URI_SCHEME_FILE, "file")
 #define SOUP_URI_SCHEME_DATA     _SOUP_ATOMIC_INTERN_STRING (_SOUP_URI_SCHEME_DATA, "data")
 #define SOUP_URI_SCHEME_RESOURCE _SOUP_ATOMIC_INTERN_STRING (_SOUP_URI_SCHEME_RESOURCE, "resource")
+#define SOUP_URI_SCHEME_WS       _SOUP_ATOMIC_INTERN_STRING (_SOUP_URI_SCHEME_WS, "ws")
+#define SOUP_URI_SCHEME_WSS      _SOUP_ATOMIC_INTERN_STRING (_SOUP_URI_SCHEME_WSS, "wss")
 extern gpointer _SOUP_URI_SCHEME_HTTP, _SOUP_URI_SCHEME_HTTPS;
 extern gpointer _SOUP_URI_SCHEME_FTP;
 extern gpointer _SOUP_URI_SCHEME_FILE, _SOUP_URI_SCHEME_DATA, _SOUP_URI_SCHEME_RESOURCE;
+extern gpointer _SOUP_URI_SCHEME_WS, _SOUP_URI_SCHEME_WSS;
 
 SoupURI           *soup_uri_new_with_base         (SoupURI    *base,
                                            const char *uri_string);


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