Mercurial > defr > drupal > scald > dnd
changeset 8:b9cd179a30a8
Use user session for the drupal_http_request requesting the library.
By default, drupal_http_request runs in a sandbox environment, thus the
request doesn't have any idea about the current user. This in turn means that
the request on the library is performed as an anonymous user, who may not have
appropriate credentials to access the library.
author | Franck Deroche <franck@defr.org> |
---|---|
date | Wed, 01 Apr 2009 15:49:44 +0200 |
parents | e6378dbabe45 |
children | a54d04d76554 |
files | dnd.module |
diffstat | 1 files changed, 3 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/dnd.module Thu Feb 19 14:10:13 2009 -0500 +++ b/dnd.module Wed Apr 01 15:49:44 2009 +0200 @@ -116,12 +116,14 @@ return t('This library is not available'); } + $headers = array(); // Handle both relative and absolute urls if (!isset($url['scheme'])) { $settings['url'] = $base_url .'/'. $settings['url']; + $headers['Cookie'] = session_name() .'='. session_id(); } - $request = drupal_http_request($settings['url']); + $request = drupal_http_request($settings['url'], $headers); // We must remove some Drupal escaping $json = json_decode(str_replace(array('\x3c', '\x3e', '\x26'), array("<", ">", "&"), $request->data), TRUE);