After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 701657 - Add rest_proxy_call_set_content
Add rest_proxy_call_set_content
Status: RESOLVED OBSOLETE
Product: librest
Classification: Platform
Component: oauth
git master
Other Linux
: Normal normal
: ---
Assigned To: librest-maint
librest-maint
Depends on:
Blocks:
 
 
Reported: 2013-06-05 15:50 UTC by Timm Bäder
Modified: 2021-05-25 12:45 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch to add rest_proxy_call_set_content (3.87 KB, patch)
2013-06-05 15:50 UTC, Timm Bäder
none Details | Review
OAuthProxyCall: Set the X-Auth-Service-Provider as header and not as parameter (960 bytes, patch)
2013-07-30 17:01 UTC, Timm Bäder
none Details | Review
RestProxyCall:Add rest_proxy_call_set_content (2.76 KB, patch)
2013-07-30 17:50 UTC, Timm Bäder
none Details | Review
RestProxyCall: Add rest_proxy_call_set_content (3.24 KB, patch)
2014-11-13 12:35 UTC, Timm Bäder
none Details | Review

Description Timm Bäder 2013-06-05 15:50:31 UTC
Created attachment 246094 [details] [review]
Patch to add rest_proxy_call_set_content

I really don't know how common this case is, but I've been experimenting with the TweetMarker API[1] and it requires me to make an OAuth Echo proxy and set the prox call's content(although the linked documentation is kinda unclear about this imo, but tests have shown that it's the only way).

Also, Twitter's OAuth Echo documentation[2] say that "The POST should contain[…] two additional items as HTTP headers: X-Auth-Service-Provider, X-Verify-Credentials-Authorization", so the following change made my code really work:

diff --git a/rest/oauth-proxy-call.c b/rest/oauth-proxy-call.c
index 63c859f..cf48fde 100644
--- a/rest/oauth-proxy-call.c
+++ b/rest/oauth-proxy-call.c
@@ -298,7 +298,7 @@ _prepare (RestProxyCall *call, GError **error)
   s = make_authorized_header (oauth_params);
   if (priv->oauth_echo) {
     rest_proxy_call_add_header (call, "X-Verify-Credentials-Authorization", s);
-    rest_proxy_call_add_param (call, "X-Auth-Service-Provider", priv->service_url);
+    rest_proxy_call_add_header (call, "X-Auth-Service-Provider", priv->service_url);
   } else {
     rest_proxy_call_add_header (call, "Authorization", s);
   }
-- 
1.8.2.2

I don't know if that is a bug or not, I also don't know of any application using librest *and* doing any OAuth Echo call and there's no example/test for it as far as I can see, so testing if that breaks anything is kinda hard.

[1] https://github.com/manton/tweetmarker/blob/master/documentation/v2.md
[2] https://dev.twitter.com/docs/auth/oauth/oauth-echo
Comment 1 Timm Bäder 2013-07-30 14:19:08 UTC
Any news/opinions about this?
Comment 2 Ross Burton 2013-07-30 14:22:32 UTC
Your "also..." comment is correct, please can you submit this as another patch.

I think that _set_content() shouldn't assume text/plain but take a byte array/size/mime-type, so that you can use it for generic posting in situations where the service wants data but doesn't want the full MIME thing.
Comment 3 Timm Bäder 2013-07-30 17:01:57 UTC
Created attachment 250487 [details] [review]
OAuthProxyCall: Set the X-Auth-Service-Provider as header and not as parameter
Comment 4 Timm Bäder 2013-07-30 17:50:08 UTC
Created attachment 250496 [details] [review]
RestProxyCall:Add rest_proxy_call_set_content

This patch is similar to the previous one but _set_content now also takes a mimetype and size argument.
Testing oauth proxies is horrible(due to dependencies 2 external services) but I quickly performed a tweetmarker test request and it worked.
Comment 5 Timm Bäder 2013-11-27 06:14:47 UTC
Any objections on this?
Comment 6 Timm Bäder 2014-07-29 10:10:05 UTC
ping
Comment 7 Timm Bäder 2014-11-13 12:35:12 UTC
Created attachment 290628 [details] [review]
RestProxyCall: Add rest_proxy_call_set_content
Comment 8 hey 2014-11-13 12:42:26 UTC
Any news on this? There is a working patch attached to this report.
Comment 9 Christophe Fergeau 2015-03-04 10:57:48 UTC
I'm wondering if it would be possible/better to add a way to achieve that through RestParam, similar to what you can do with

RestParam *param = rest_param_new_full("foo", REST_MEMORY_COPY, "barbaz", 7, "x-foo/x-bar", NULL);
rest_proxy_call_add_param_full (call, param);

How is this supposed to interact with serialize_params and multipart messages (generated using the API mentioned above)? At the moment, I think it will overwrite what is returned by serialize_params, and behaviour is weird with multipart message (this changes Content-Type, but not the body, could be a libsoup bug).
Imo the behaviour should be consistent. Ideally we would not overwrite any of these, but we should at least have a warning when this happens (?)
Should set_content have a RestMemoryUse parameter ?
Comment 10 Timm Bäder 2015-03-22 11:39:55 UTC
(In reply to Christophe Fergeau from comment #9)
> I'm wondering if it would be possible/better to add a way to achieve that
> through RestParam, similar to what you can do with
> 
> RestParam *param = rest_param_new_full("foo", REST_MEMORY_COPY, "barbaz", 7,
> "x-foo/x-bar", NULL);
> rest_proxy_call_add_param_full (call, param);

Not sure how the API would really look. Would you look at the content_type and just use the data of a x-proxy-call-contents (or similar) param as the call's contents? What happens when adding multiple such RestParams?


> How is this supposed to interact with serialize_params and multipart
> messages (generated using the API mentioned above)? At the moment, I think
> it will overwrite what is returned by serialize_params, and behaviour is
> weird with multipart message (this changes Content-Type, but not the body,
> could be a libsoup bug).

Yes, it seems to just override anything serialize_params does (haven't looked at the patch myself in a while...). I mean, *set*_content is pretty clear about the behavior  (i.e. it would set/overwrite all contents) and I don't know if an API using both normal params *and* a custom content can ever work or exists.


> Imo the behaviour should be consistent. Ideally we would not overwrite any
> of these, but we should at least have a warning when this happens (?)

Not overwrite what? I mean, we have to overwrite the message's contents of course, I guess you mean the other parameters?


> Should set_content have a RestMemoryUse parameter ?

You tell me? :) I'm not overly familiar with the libsoup API, I guess that's just an optimization to not copy the data if that's not necessary?
Comment 11 Christophe Fergeau 2015-03-25 17:29:04 UTC
I discussed this on IRC with Timm to get more details about the use case of this new method. In particular I asked if subclassing RestProxyCall and overriding RestProxyCall::serialize would be enough for what this TweetMarker interaction.
This is what https://git.gnome.org/browse/libgovirt/tree/govirt/ovirt-action-rest-call.c is doing to serialize RestParams to XML and set the request body to contain that XML data.
Comment 12 André Klapper 2021-05-25 12:45:59 UTC
GNOME is going to shut down bugzilla.gnome.org in favor of gitlab.gnome.org.
As part of that, we are mass-closing older open tickets in bugzilla.gnome.org
which have not seen updates for a longer time (resources are unfortunately
quite limited so not every ticket can get handled).

If you can still reproduce the situation described in this ticket in a recent
and supported software version, then please follow
  https://wiki.gnome.org/GettingInTouch/BugReportingGuidelines
and create a new enhancement request ticket at
  https://gitlab.gnome.org/GNOME/librest/-/issues/

Thank you for your understanding and your help.