static void redirect_handler (SoupMessage *msg, gpointer user_data) { if (SOUP_STATUS_IS_REDIRECTION (msg->status_code)) { CallbackInfo *info = user_data; SoupURI *new_uri; const gchar *new_loc; new_loc = soup_message_headers_get (msg->response_headers, "Location"); if (!new_loc) return; info->reset=1; new_uri = soup_uri_new_with_base (soup_message_get_uri (msg), new_loc); if (!new_uri) { soup_message_set_status_full (msg, SOUP_STATUS_MALFORMED, "Invalid Redirect URL"); return; } soup_message_set_uri (msg, new_uri); soup_session_requeue_message (info->ss, msg); soup_uri_free (new_uri); } }
static void got_chunk_cb(SoupMessage *msg, SoupBuffer *chunk, CallbackInfo *info) { NetStatusProgress *progress = NULL; const char* clen; clen = soup_message_headers_get(msg->response_headers, "Content-length"); if (!clen) info->total = 0; else info->total = atoi(clen); info->current += chunk->length; info->chunk = (gchar *)chunk->data; progress = g_new0(NetStatusProgress, 1); progress->current = info->current; progress->total = info->total; progress->chunk = (gchar *)chunk->data; progress->chunksize = (gint)chunk->length; if (info->reset) { progress->reset = info->reset; info->reset = 0; } info->user_cb(NET_STATUS_PROGRESS, progress, info->user_data); g_free(progress); }
got_chunk_blocking_cb(SoupMessage *msg, SoupBuffer *chunk, CallbackInfo *info) { #endif NetStatusProgress progress = {0}; const char* clen; if (info->total == 0) { #if LIBSOUP_VERSION < 2003000 clen = soup_message_get_header(msg->response_headers, "Content-length"); #else clen = soup_message_headers_get(msg->response_headers, "Content-length"); #endif if (!clen) return; info->total = atoi(clen); } #if LIBSOUP_VERSION < 2003000 info->current += msg->response.length; #else info->current += chunk->length; #endif progress.current = info->current; progress.total = info->total; info->user_cb(NET_STATUS_PROGRESS, &progress, info->user_data); }
static gint rygel_seekable_response_get_requested_priority (RygelSeekableResponse* self) { const char* _tmp0_; char* mode; gboolean _tmp1_; g_return_val_if_fail (self != NULL, 0); _tmp0_ = NULL; mode = (_tmp0_ = soup_message_headers_get (((RygelHTTPResponse*) self)->msg->request_headers, "transferMode.dlna.org"), (_tmp0_ == NULL) ? NULL : g_strdup (_tmp0_)); _tmp1_ = FALSE; if (mode == NULL) { _tmp1_ = TRUE; } else { _tmp1_ = _vala_strcmp0 (mode, "Interactive") == 0; } if (_tmp1_) { gint _tmp2_; return (_tmp2_ = G_PRIORITY_DEFAULT, mode = (g_free (mode), NULL), _tmp2_); } else { if (_vala_strcmp0 (mode, "Streaming") == 0) { gint _tmp3_; return (_tmp3_ = G_PRIORITY_HIGH, mode = (g_free (mode), NULL), _tmp3_); } else { if (_vala_strcmp0 (mode, "Background") == 0) { gint _tmp4_; return (_tmp4_ = G_PRIORITY_LOW, mode = (g_free (mode), NULL), _tmp4_); } else { gint _tmp5_; return (_tmp5_ = G_PRIORITY_DEFAULT, mode = (g_free (mode), NULL), _tmp5_); } } } mode = (g_free (mode), NULL); }
static gint rygel_seekable_response_get_requested_priority (RygelSeekableResponse* self) { #line 918 "rygel-seekable-response.c" gint result = 0; char* mode; gboolean _tmp0_ = FALSE; #line 164 "rygel-seekable-response.vala" g_return_val_if_fail (self != NULL, 0); #line 165 "rygel-seekable-response.vala" mode = g_strdup (soup_message_headers_get (((RygelHTTPResponse*) self)->msg->request_headers, "transferMode.dlna.org")); #line 167 "rygel-seekable-response.vala" if (mode == NULL) { #line 167 "rygel-seekable-response.vala" _tmp0_ = TRUE; #line 930 "rygel-seekable-response.c" } else { #line 167 "rygel-seekable-response.vala" _tmp0_ = _vala_strcmp0 (mode, "Interactive") == 0; #line 934 "rygel-seekable-response.c" } #line 167 "rygel-seekable-response.vala" if (_tmp0_) { #line 938 "rygel-seekable-response.c" result = G_PRIORITY_DEFAULT; _g_free0 (mode); #line 168 "rygel-seekable-response.vala" return result; #line 943 "rygel-seekable-response.c" } else { #line 169 "rygel-seekable-response.vala" if (_vala_strcmp0 (mode, "Streaming") == 0) { #line 947 "rygel-seekable-response.c" result = G_PRIORITY_HIGH; _g_free0 (mode); #line 170 "rygel-seekable-response.vala" return result; #line 952 "rygel-seekable-response.c" } else { #line 171 "rygel-seekable-response.vala" if (_vala_strcmp0 (mode, "Background") == 0) { #line 956 "rygel-seekable-response.c" result = G_PRIORITY_LOW; _g_free0 (mode); #line 172 "rygel-seekable-response.vala" return result; #line 961 "rygel-seekable-response.c" } else { result = G_PRIORITY_DEFAULT; _g_free0 (mode); #line 174 "rygel-seekable-response.vala" return result; #line 967 "rygel-seekable-response.c" } } } _g_free0 (mode); }
static void rygel_mediathek_rss_container_on_feed_got (RygelMediathekRssContainer* self, SoupSession* session, SoupMessage* msg) { #line 129 "rygel-mediathek-rss-container.c" guint _tmp0_; #line 31 "rygel-mediathek-rss-container.vala" g_return_if_fail (self != NULL); #line 31 "rygel-mediathek-rss-container.vala" g_return_if_fail (session != NULL); #line 31 "rygel-mediathek-rss-container.vala" g_return_if_fail (msg != NULL); #line 32 "rygel-mediathek-rss-container.vala" switch ((g_object_get (msg, "status-code", &_tmp0_, NULL), _tmp0_)) { #line 139 "rygel-mediathek-rss-container.c" case 304: { #line 34 "rygel-mediathek-rss-container.vala" g_message ("rygel-mediathek-rss-container.vala:34: %s", _ ("Feed has not changed, nothing to do")); #line 35 "rygel-mediathek-rss-container.vala" break; #line 146 "rygel-mediathek-rss-container.c" } case 200: { #line 37 "rygel-mediathek-rss-container.vala" if (rygel_mediathek_rss_container_parse_response (self, (const char*) msg->response_body->data, (gsize) msg->response_body->length)) { #line 152 "rygel-mediathek-rss-container.c" SoupDate* _tmp1_; #line 39 "rygel-mediathek-rss-container.vala" self->priv->last_modified = (_tmp1_ = soup_date_new_from_string (soup_message_headers_get (msg->response_headers, "Date")), _soup_date_free0 (self->priv->last_modified), _tmp1_); #line 156 "rygel-mediathek-rss-container.c" } #line 42 "rygel-mediathek-rss-container.vala" break; #line 160 "rygel-mediathek-rss-container.c" } default: { guint _tmp2_; guint _tmp3_; #line 45 "rygel-mediathek-rss-container.vala" g_warning (_ ("Got unexpected response %u (%s)"), (g_object_get (msg, "status-code", &_tmp2_, NULL), _tmp2_), soup_status_get_phrase ((g_object_get (msg, "status-code", &_tmp3_, NULL), _tmp3_))); #line 48 "rygel-mediathek-rss-container.vala" break; #line 170 "rygel-mediathek-rss-container.c" } } }
static void fillResponseFromMessage(SoupMessage* msg, ResourceResponse* response) { SoupMessageHeadersIter iter; const char* name = NULL; const char* value = NULL; soup_message_headers_iter_init(&iter, msg->response_headers); while (soup_message_headers_iter_next(&iter, &name, &value)) response->setHTTPHeaderField(name, value); String contentType = soup_message_headers_get(msg->response_headers, "Content-Type"); char* uri = soup_uri_to_string(soup_message_get_uri(msg), FALSE); response->setUrl(KURL(uri)); g_free(uri); response->setMimeType(extractMIMETypeFromMediaType(contentType)); response->setTextEncodingName(extractCharsetFromMediaType(contentType)); response->setExpectedContentLength(soup_message_headers_get_content_length(msg->response_headers)); response->setHTTPStatusCode(msg->status_code); response->setSuggestedFilename(filenameFromHTTPContentDisposition(response->httpHeaderField("Content-Disposition"))); }
void e_gw_message_write_footer (SoupSoapMessage *msg) { soup_soap_message_end_element (msg); soup_soap_message_end_body (msg); soup_soap_message_end_envelope (msg); soup_soap_message_persist (msg); if (g_getenv ("GROUPWISE_DEBUG") && (atoi (g_getenv ("GROUPWISE_DEBUG")) == 1)) { const gchar *header = soup_message_headers_get (SOUP_MESSAGE (msg)->request_headers, "SOAPAction"); soup_buffer_free (soup_message_body_flatten (SOUP_MESSAGE (msg)->request_body)); if (header && g_str_equal (header, "loginRequest")) { gchar *body; gchar *begin = NULL; gchar *end = NULL; body = g_strdup (SOUP_MESSAGE (msg)->request_body->data); begin = g_strrstr (body, "<types:password>"); if (begin) begin = begin + strlen ("<types:password>"); end = g_strrstr (body , "</types:password>"); if (begin && end) { gchar *tmp; for (tmp = begin; tmp < end; tmp++) *tmp='X'; } fputc ('\n', stdout); fputs (body, stdout); fputc ('\n', stdout); g_free (body); } else { /* print request's body */ fputc ('\n', stdout); fputs (SOUP_MESSAGE (msg)->request_body->data, stdout); fputc ('\n', stdout); } } }
static void gst_soup_http_src_got_headers_cb (SoupMessage * msg, GstSoupHTTPSrc * src) { const char *value; GstTagList *tag_list; GstBaseSrc *basesrc; guint64 newsize; GHashTable *params = NULL; GST_DEBUG_OBJECT (src, "got headers:"); soup_message_headers_foreach (msg->response_headers, gst_soup_http_src_headers_foreach, src); if (src->automatic_redirect && SOUP_STATUS_IS_REDIRECTION (msg->status_code)) { GST_DEBUG_OBJECT (src, "%u redirect to \"%s\"", msg->status_code, soup_message_headers_get (msg->response_headers, "Location")); return; } if (msg->status_code == SOUP_STATUS_UNAUTHORIZED) return; src->session_io_status = GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_RUNNING; /* Parse Content-Length. */ if (soup_message_headers_get_encoding (msg->response_headers) == SOUP_ENCODING_CONTENT_LENGTH) { newsize = src->request_position + soup_message_headers_get_content_length (msg->response_headers); if (!src->have_size || (src->content_size != newsize)) { src->content_size = newsize; src->have_size = TRUE; src->seekable = TRUE; GST_DEBUG_OBJECT (src, "size = %" G_GUINT64_FORMAT, src->content_size); basesrc = GST_BASE_SRC_CAST (src); gst_segment_set_duration (&basesrc->segment, GST_FORMAT_BYTES, src->content_size); gst_element_post_message (GST_ELEMENT (src), gst_message_new_duration (GST_OBJECT (src), GST_FORMAT_BYTES, src->content_size)); } } /* Icecast stuff */ tag_list = gst_tag_list_new (); if ((value = soup_message_headers_get (msg->response_headers, "icy-metaint")) != NULL) { gint icy_metaint = atoi (value); GST_DEBUG_OBJECT (src, "icy-metaint: %s (parsed: %d)", value, icy_metaint); if (icy_metaint > 0) { if (src->src_caps) gst_caps_unref (src->src_caps); src->src_caps = gst_caps_new_simple ("application/x-icy", "metadata-interval", G_TYPE_INT, icy_metaint, NULL); } } if ((value = soup_message_headers_get_content_type (msg->response_headers, ¶ms)) != NULL) { GST_DEBUG_OBJECT (src, "Content-Type: %s", value); if (g_ascii_strcasecmp (value, "audio/L16") == 0) { gint channels = 2; gint rate = 44100; char *param; if (src->src_caps) gst_caps_unref (src->src_caps); param = g_hash_table_lookup (params, "channels"); if (param != NULL) channels = atol (param); param = g_hash_table_lookup (params, "rate"); if (param != NULL) rate = atol (param); src->src_caps = gst_caps_new_simple ("audio/x-raw-int", "channels", G_TYPE_INT, channels, "rate", G_TYPE_INT, rate, "width", G_TYPE_INT, 16, "depth", G_TYPE_INT, 16, "signed", G_TYPE_BOOLEAN, TRUE, "endianness", G_TYPE_INT, G_BIG_ENDIAN, NULL); } else { /* Set the Content-Type field on the caps */ if (src->src_caps) gst_caps_set_simple (src->src_caps, "content-type", G_TYPE_STRING, value, NULL); } } if (params != NULL) g_hash_table_destroy (params); if ((value = soup_message_headers_get (msg->response_headers, "icy-name")) != NULL) { g_free (src->iradio_name); src->iradio_name = gst_soup_http_src_unicodify (value); if (src->iradio_name) { g_object_notify (G_OBJECT (src), "iradio-name"); gst_tag_list_add (tag_list, GST_TAG_MERGE_REPLACE, GST_TAG_ORGANIZATION, src->iradio_name, NULL); } } if ((value = soup_message_headers_get (msg->response_headers, "icy-genre")) != NULL) { g_free (src->iradio_genre); src->iradio_genre = gst_soup_http_src_unicodify (value); if (src->iradio_genre) { g_object_notify (G_OBJECT (src), "iradio-genre"); gst_tag_list_add (tag_list, GST_TAG_MERGE_REPLACE, GST_TAG_GENRE, src->iradio_genre, NULL); } } if ((value = soup_message_headers_get (msg->response_headers, "icy-url")) != NULL) { g_free (src->iradio_url); src->iradio_url = gst_soup_http_src_unicodify (value); if (src->iradio_url) { g_object_notify (G_OBJECT (src), "iradio-url"); gst_tag_list_add (tag_list, GST_TAG_MERGE_REPLACE, GST_TAG_LOCATION, src->iradio_url, NULL); } } if (!gst_tag_list_is_empty (tag_list)) { GST_DEBUG_OBJECT (src, "calling gst_element_found_tags with %" GST_PTR_FORMAT, tag_list); gst_element_found_tags (GST_ELEMENT_CAST (src), tag_list); } else { gst_tag_list_free (tag_list); } /* Handle HTTP errors. */ gst_soup_http_src_parse_status (msg, src); /* Check if Range header was respected. */ if (src->ret == GST_FLOW_CUSTOM_ERROR && src->read_position && msg->status_code != SOUP_STATUS_PARTIAL_CONTENT) { src->seekable = FALSE; GST_ELEMENT_ERROR (src, RESOURCE, SEEK, (_("Server does not support seeking.")), ("Server does not accept Range HTTP header, URL: %s", src->location)); src->ret = GST_FLOW_ERROR; } }
static void actual_http_response_handler (DAAPResponseData * data) { DMAPConnectionPrivate *priv; GNode *structure; char *new_response = NULL; const char *response; const char *encoding_header; char *message_path; int response_length; gboolean compatible_server = TRUE; priv = data->connection->priv; structure = NULL; encoding_header = NULL; response = data->message->response_body->data; response_length = data->message->response_body->length; message_path = soup_uri_to_string (soup_message_get_uri (data->message), FALSE); g_debug ("Received response from %s: %d, %s\n", message_path, data->message->status_code, data->message->reason_phrase); if (data->message->response_headers) { const char *server; encoding_header = soup_message_headers_get (data-> message->response_headers, "Content-Encoding"); server = soup_message_headers_get (data-> message->response_headers, "DAAP-Server"); if (server != NULL && strstr (server, ITUNES_7_SERVER) != NULL) { g_debug ("giving up. we can't talk to %s", server); compatible_server = FALSE; } } if (SOUP_STATUS_IS_SUCCESSFUL (data->status) && encoding_header && strcmp (encoding_header, "gzip") == 0) { #ifdef HAVE_LIBZ z_stream stream; unsigned int factor = 4; unsigned int unc_size = response_length * factor; stream.next_in = (unsigned char *) response; stream.avail_in = response_length; stream.total_in = 0; new_response = g_malloc (unc_size + 1); stream.next_out = (unsigned char *) new_response; stream.avail_out = unc_size; stream.total_out = 0; stream.zalloc = g_zalloc_wrapper; stream.zfree = g_zfree_wrapper; stream.opaque = NULL; if (inflateInit2 (&stream, 32 /* auto-detect */ + 15 /* max */ ) != Z_OK) { inflateEnd (&stream); g_free (new_response); g_debug ("Unable to decompress response from %s", message_path); data->status = SOUP_STATUS_MALFORMED; } else { do { int z_res; z_res = inflate (&stream, Z_FINISH); if (z_res == Z_STREAM_END) { break; } if ((z_res != Z_OK && z_res != Z_BUF_ERROR) || stream.avail_out != 0 || unc_size > 40 * 1000 * 1000) { inflateEnd (&stream); g_free (new_response); new_response = NULL; break; } factor *= 4; unc_size = (response_length * factor); /* unc_size can't grow bigger than 40MB, so * unc_size can't overflow, and this realloc * call is safe */ new_response = g_realloc (new_response, unc_size + 1); stream.next_out = (unsigned char *) (new_response + stream.total_out); stream.avail_out = unc_size - stream.total_out; } while (1); } if (new_response) { response = new_response; response_length = stream.total_out; } #else g_debug ("Received compressed response from %s but can't handle it", message_path); data->status = SOUP_STATUS_MALFORMED; #endif } if (compatible_server == FALSE) { /* leaving structure == NULL here causes the connection process * to fail at the first step. */ connection_set_error_message (data->connection, ("libdmapsharing is not able to connect to iTunes 7 shares")); } else if (SOUP_STATUS_IS_SUCCESSFUL (data->status)) { DMAPStructureItem *item; if ( /* FIXME: !rb_is_main_thread () */ TRUE) { priv->progress = -1.0f; if (priv->emit_progress_id != 0) { g_source_remove (priv->emit_progress_id); } priv->emit_progress_id = g_idle_add ((GSourceFunc) emit_progress_idle, data->connection); } structure = dmap_structure_parse (response, response_length); if (structure == NULL) { g_debug ("No daap structure returned from %s", message_path); data->status = SOUP_STATUS_MALFORMED; } else { int dmap_status = 0; item = dmap_structure_find_item (structure, DMAP_CC_MSTT); if (item) { dmap_status = g_value_get_int (&(item->content)); if (dmap_status != 200) { g_debug ("Error, dmap.status is not 200 in response from %s", message_path); data->status = SOUP_STATUS_MALFORMED; } } } if ( /* FIXME: ! rb_is_main_thread () */ TRUE) { priv->progress = 1.0f; if (priv->emit_progress_id != 0) { g_source_remove (priv->emit_progress_id); } priv->emit_progress_id = g_idle_add ((GSourceFunc) emit_progress_idle, data->connection); } } else { g_debug ("Error getting %s: %d, %s\n", message_path, data->message->status_code, data->message->reason_phrase); connection_set_error_message (data->connection, data->message->reason_phrase); } if (data->response_handler) { (*(data->response_handler)) (data->connection, data->status, structure, data->user_data); } if (structure) { dmap_structure_destroy (structure); } g_free (new_response); g_free (message_path); g_object_unref (G_OBJECT (data->connection)); g_object_unref (G_OBJECT (data->message)); g_free (data); }