#include "soup-request-data.h"
#include "soup-requester.h"
+#include "soup-uri-private.h"
#include <libsoup/soup.h>
#include <glib/gi18n.h>
} else
end = comma;
- if (end != start) {
- char *encoded_content_type = g_strndup (start, end - start);
-
- if (base64)
- data->priv->content_type = encoded_content_type;
- else {
- data->priv->content_type = soup_uri_decode (encoded_content_type);
- g_free (encoded_content_type);
- }
- }
+ if (end != start)
+ data->priv->content_type = uri_decoded_copy (start, end - start);
}
memstream = g_memory_input_stream_new ();
start = comma + 1;
if (*start) {
- guchar *buf;
-
- if (base64) {
- int inlen, state = 0;
- guint save = 0;
-
- inlen = strlen (start);
- buf = g_malloc0 (inlen * 3 / 4 + 3);
- data->priv->content_length =
- g_base64_decode_step (start, inlen, buf,
- &state, &save);
- if (state != 0) {
- g_free (buf);
- goto fail;
- }
- } else {
- buf = (guchar *) soup_uri_decode (start);
+ guchar *buf = (guchar *) soup_uri_decode (start);
+
+ if (base64)
+ buf = g_base64_decode_inplace ((gchar*) buf, &data->priv->content_length);
+ else
data->priv->content_length = strlen ((const char *) buf);
- }
g_memory_input_stream_add_data (G_MEMORY_INPUT_STREAM (memstream),
buf, data->priv->content_length,
g_free (uristr);
return memstream;
-
- fail:
- g_free (uristr);
- g_set_error (error, SOUP_REQUESTER_ERROR, SOUP_REQUESTER_ERROR_BAD_URI,
- _("Unable to decode URI: %s"), start);
- g_object_unref (memstream);
- return NULL;
}
static goffset
--- /dev/null
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2011 Igalia, S.L.
+ */
+
+#ifndef SOUP_URI_PRIVATE_H
+#define SOUP_URI_PRIVATE_H 1
+
+char *uri_decoded_copy (const char *str, int length);
+
+#endif /* SOUP_URI_PRIVATE_H */
#include <stdlib.h>
#include "soup-uri.h"
+#include "soup-uri-private.h"
#include "soup-form.h"
#include "soup-misc.h"
**/
static void append_uri_encoded (GString *str, const char *in, const char *extra_enc_chars);
-static char *uri_decoded_copy (const char *str, int length);
static char *uri_normalized_copy (const char *str, int length, const char *unescape_extra);
gpointer _SOUP_URI_SCHEME_HTTP, _SOUP_URI_SCHEME_HTTPS;
#define XDIGIT(c) ((c) <= '9' ? (c) - '0' : ((c) & 0x4F) - 'A' + 10)
#define HEXCHAR(s) ((XDIGIT (s[1]) << 4) + XDIGIT (s[2]))
-static char *
+char *
uri_decoded_copy (const char *part, int length)
{
unsigned char *s, *d;