Summary:ASTERISK-03093: [patch] Adds POSTing ability to new app_curl
Date Opened:2004-12-24 13:33:52.000-0600Date Closed:2008-01-15 15:19:57.000-0600
Versions:Frequency of
Environment:Attachments:( 0) 20041228__curl_post.diff.txt
( 1) app_curl.diff.txt
Description:I desired the ability to POST with app_curl since our system relies on POST since it is more secure in a sense. This adds the ability to POST to a page and specify the arguments by doing Curl(url|postdata). If no arguments are specified, the application knows by default that the page will be retrieved via GET. You can still specify GET arguments in the URL.


Disclaimer on file.

Not tested, but compiles sucessfully.
Comments:By: () 2004-12-24 13:34:44.000-0600

Oops, forgot to put [patch] on the subject line. Marshalls please edit subject line. Thanks

By: Olle Johansson (oej) 2004-12-25 02:44:45.000-0600

OK, confirm when you have tested (or others) so that we know before adding it to cvs.

By: Tilghman Lesher (tilghman) 2004-12-25 22:24:14.000-0600

Please reupload your patch, following the code guidelines, in particular the tab-indenting.  Your editor seems to have converted all of the tabs into spaces.

Also, note that by convention, we do argument parsing using the strsep(3) function.

Third, you should be using the macro LOCAL_USER_ADD(u) as early as possible in the code, as this is what prevents executing code from being unloaded.

By: Mark Spencer (markster) 2004-12-26 18:51:56.000-0600

Looks promising.  Waiting for the version with correct tabs and parsing fixes.  Thanks!

By: () 2004-12-27 10:37:26.000-0600

Posted another file with corrections. Tested, works fine.

By: Tilghman Lesher (tilghman) 2004-12-27 11:51:30.000-0600

Looks good, other than the changing of tabs to spaces.  You still need to fix that.

By: () 2004-12-28 07:50:22.000-0600

mmmm k, I have used three different editors: vim, kate, and crimson - to no avail. I promise I use no spaces. Any clues? Thanks.

By: Tilghman Lesher (tilghman) 2004-12-28 18:05:38.000-0600

No idea what's wrong with your editor, but I went ahead and cleaned up the patch for you.  I removed quite a bit of superfluous code; you may want to compare the usage of strsep(3) to see just how much extra code you had added unnecessarily.

Also, it appears you aren't generating your patches out of CVS with the 'cvs diff -u apps/app_curl.c' command, which should make the changes from tabs to spaces quite apparent.

By: Tilghman Lesher (tilghman) 2004-12-28 18:13:01.000-0600

Oh, and there was another problem (bug) in your code:  by defaulting post_data to "" and then later checking 'if (post_data)' would always be true, making the code always generate a POST rather than conditionally on the arguments.  This has also been fixed in the uploaded patch.

By: () 2004-12-30 07:53:25.000-0600

Thanks for the fixes. I'll apply them and test them later today, then report back here on success.

By: () 2004-12-31 08:48:54.000-0600

Problems patching :

asterisk:/usr/src/asterisk/apps# patch --verbose -p1 < 20041228__curl_post.diff.txt
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
|Index: apps/app_curl.c
|RCS file: /usr/cvsroot/asterisk/apps/app_curl.c,v
|retrieving revision 1.1
|diff -u -r1.1 app_curl.c
|--- apps/app_curl.c     23 Dec 2004 02:55:53 -0000      1.1
|+++ apps/app_curl.c     29 Dec 2004 00:00:18 -0000
Patching file app_curl.c using Plan A...
Hunk #1 succeeded at 6.
Hunk #2 FAILED at 31.
Hunk #3 FAILED at 76.
Hunk #4 FAILED at 102.
3 out of 4 hunks FAILED -- saving rejects to file app_curl.c.rej

By: Tilghman Lesher (tilghman) 2004-12-31 10:04:23.000-0600

Did you already back out your original patch before applying this one?

i.e. cd /usr/src/asterisk && rm -f apps/app_curl.c && make update && patch -p0 < 20041228__curl_post.diff.txt

By: () 2004-12-31 12:14:15.000-0600

Yes I did. Same problem. I'll apply the code changes manually.

By: Tilghman Lesher (tilghman) 2004-12-31 12:31:46.000-0600

Aha.  How did you save out the patch?  I'm noting that the first section of the patch contains no tabs, while the next three all contain tabs.

By: () 2004-12-31 12:36:34.000-0600

File/Save As.. in Mozilla Firefox, then scp'd it to my test machine. I went ahead and typed the changes in manually since they weren't that long. Deleting all CVS files and directories, then applying patch did not work.

By: nick (nick) 2004-12-31 12:59:50.000-0600

The patch applies cleanly for me.

brian: are you sure you have a fresh copy of app_curl.c from cvs?  As in, you've deleted it and then done 'cvs update'?

By: Tilghman Lesher (tilghman) 2004-12-31 13:16:54.000-0600

Or another method might be appropriate:  download the file directly on your Linux machine, using lynx, w3m, or another browser, and try the patch from there.

By: () 2004-12-31 18:04:02.000-0600

Using wget, the file downloads cleanly and applies cleanly. Firefox must mangle the file somehow. Anyhow, I applied it earlier and it works. Just FYI, I did do a cvs update and had a problem when I tried applying the patch downloaded via FireFox. After doing wget it works fine. Lessons learned..

I think the patch is ready for CVS if we are done with testing.

By: () 2005-01-04 10:35:29.000-0600

Anyone else having any other issues? I'm using it now with no problems that I can see.

By: () 2005-01-04 10:36:12.000-0600

20041228__curl_post_diff.txt is the correct patch FYI.

By: Mark Spencer (markster) 2005-01-05 00:33:42.000-0600

Added to CVS, thanks.

By: Digium Subversion (svnbot) 2008-01-15 15:19:57.000-0600

Repository: asterisk
Revision: 4673

U   trunk/apps/app_curl.c

r4673 | markster | 2008-01-15 15:19:57 -0600 (Tue, 15 Jan 2008) | 2 lines

Allow post data, too (bug ASTERISK-3093)



By: Alexandre Keller (alexandrekeller) 2020-07-13 09:51:53.233-0500

I've been trying to use CURL with POSTDATA set as: --binary @file.wav

Set(POSTDATA=--data-binary @64.wav)

but it is not working, any help?