GNOME Bugzilla – Bug 703229
The "get" example outputs the data in the body to stdout without chance of redirecting
Last modified: 2013-07-03 07:54:56 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.
Created attachment 247957 [details] [review] Added -o to Write the output to stderr rather than stdout
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?)
(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).
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 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
Thanks for the review. Modified following the comments and pushed to master.