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 703229 - The "get" example outputs the data in the body to stdout without chance of redirecting
The "get" example outputs the data in the body to stdout without chance of re...
Status: RESOLVED FIXED
Product: libsoup
Classification: Core
Component: Misc
2.43.x
Other Linux
: Normal enhancement
: ---
Assigned To: libsoup-maint@gnome.bugs
libsoup-maint@gnome.bugs
Depends on:
Blocks:
 
 
Reported: 2013-06-28 09:06 UTC by Andres Gomez
Modified: 2013-07-03 07:54 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Added -o to Write the output to stderr rather than stdout (2.04 KB, patch)
2013-06-28 09:06 UTC, Andres Gomez
needs-work Details | Review
[examples] "get" uses -o to save to a file (2.58 KB, patch)
2013-07-02 16:15 UTC, Andres Gomez
reviewed Details | Review

Description Andres Gomez 2013-06-28 09:06:06 UTC
As the body of the response message is always printed in stdout, it is quite messy for checking the rest of the output with the -d or -h flags.

Also, it is not possible to redirect cleanly to a file, unless using the -q flag.

It would be good at least to be able to chose to redirect the output of the message to stdout or stderr, for example.
Comment 1 Andres Gomez 2013-06-28 09:06:46 UTC
Created attachment 247957 [details] [review]
Added -o to Write the output to stderr rather than stdout
Comment 2 Dan Winship 2013-06-29 16:52:05 UTC
Comment on attachment 247957 [details] [review]
Added -o to Write the output to stderr rather than stdout

I think it's confusing to have "-o" unconditionally mean "write to stderr". It would make more sense to me to have "-o FILENAME", to redirect to a file.

(btw, do you have gnome commit access?)
Comment 3 Andres Gomez 2013-07-02 16:08:41 UTC
(In reply to comment #2)
> (From update of attachment 247957 [details] [review])
> I think it's confusing to have "-o" unconditionally mean "write to stderr". It
> would make more sense to me to have "-o FILENAME", to redirect to a file.

Yes, I suppose I was just lazy as stderr was just enough for me O:)

> (btw, do you have gnome commit access?)

Yes (or I should).
Comment 4 Andres Gomez 2013-07-02 16:15:41 UTC
Created attachment 248244 [details] [review]
[examples] "get" uses -o to save to a file

The "get" example is now able to handle a new "-o"
parameter specifying the path of a file in which
to write the received body of a "GET" operation.

If the file exists, it will be overwritten.
Comment 5 Dan Winship 2013-07-02 21:37:34 UTC
Comment on attachment 248244 [details] [review]
[examples] "get" uses -o to save to a file

>+			if (!output_file) {
>+				g_print ("Error trying to create file %s.\n", output_file_path);
>+			}

don't need {}s there, and you should use g_printerr() (to print to stderr)

>+			fclose (output_file);

You should probably only do that if it's not stdout (aka, if output_file_path is set). We might want to print something else to stdout after that in some case, so we don't want to close that.


ok to commit with those fixes
Comment 6 Andres Gomez 2013-07-03 07:54:56 UTC
Thanks for the review.

Modified following the comments and pushed to master.