diff options
author | Russell Bryant <russell@russellbryant.com> | 2007-04-06 21:16:38 +0000 |
---|---|---|
committer | Russell Bryant <russell@russellbryant.com> | 2007-04-06 21:16:38 +0000 |
commit | 0a9750ef9f61a12070797f3475f8f5b6b07f21b4 (patch) | |
tree | d1a8725b9d1a7d8508205ad650f4a6ed1de11339 /main/minimime/mytest_files | |
parent | e3192c77f2e1afacef8ce5a20ee14ef70c1aba9e (diff) |
Merged revisions 60603 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r60603 | russell | 2007-04-06 15:58:43 -0500 (Fri, 06 Apr 2007) | 13 lines
To be able to achieve the things that we would like to achieve with the
Asterisk GUI project, we need a fully functional HTTP interface with access
to the Asterisk manager interface. One of the things that was intended to be
a part of this system, but was never actually implemented, was the ability for
the GUI to be able to upload files to Asterisk. So, this commit adds this in
the most minimally invasive way that we could come up with.
A lot of work on minimime was done by Steve Murphy. He fixed a lot of bugs in
the parser, and updated it to be thread-safe. The ability to check
permissions of active manager sessions was added by Dwayne Hubbard. Then,
hacking this all together and do doing the modifications necessary to the HTTP
interface was done by me.
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@60604 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/minimime/mytest_files')
-rw-r--r-- | main/minimime/mytest_files/ast_postdata | 38 | ||||
-rw-r--r-- | main/minimime/mytest_files/ast_postdata2 | bin | 0 -> 1737 bytes | |||
-rw-r--r-- | main/minimime/mytest_files/ast_postdata3.gz | bin | 0 -> 526318 bytes | |||
-rw-r--r-- | main/minimime/mytest_files/mytest.c | 71 |
4 files changed, 109 insertions, 0 deletions
diff --git a/main/minimime/mytest_files/ast_postdata b/main/minimime/mytest_files/ast_postdata new file mode 100644 index 000000000..c3776c6f4 --- /dev/null +++ b/main/minimime/mytest_files/ast_postdata @@ -0,0 +1,38 @@ +MyHeader1: blah1
+MyHeader2: blah2
+MyHeader3: blah3
+MyHeader4: blah4
+Content-Type: multipart/form-data; boundary=---------------------------175757342718946221771693683144
+
+-----------------------------175757342718946221771693683144
+Content-Disposition: form-data; name="MAX_FILE_SIZE"
+
+30000
+-----------------------------175757342718946221771693683144
+Content-Disposition: form-data; name="userfile"; filename="BUGS"
+Content-Type: application/octet-stream
+
+Asterisk Bug Tracking Information
+=================================
+
+To learn about and report Asterisk bugs, please visit
+the official Asterisk Bug Tracker at:
+
+ http://bugs.digium.com
+
+For more information on using the bug tracker, or to
+learn how you can contribute by acting as a bug marshall
+please see:
+
+ http://www.asterisk.org/developers/bug-guidelines
+
+If you would like to submit a feature request, please
+resist the temptation to post it to the bug tracker.
+Feature requests should be posted to the asterisk-dev
+mailing list, located at:
+
+ http://lists.digium.com
+
+Thank you!
+
+-----------------------------175757342718946221771693683144--
diff --git a/main/minimime/mytest_files/ast_postdata2 b/main/minimime/mytest_files/ast_postdata2 Binary files differnew file mode 100644 index 000000000..8f91e7a51 --- /dev/null +++ b/main/minimime/mytest_files/ast_postdata2 diff --git a/main/minimime/mytest_files/ast_postdata3.gz b/main/minimime/mytest_files/ast_postdata3.gz Binary files differnew file mode 100644 index 000000000..d8d3894ad --- /dev/null +++ b/main/minimime/mytest_files/ast_postdata3.gz diff --git a/main/minimime/mytest_files/mytest.c b/main/minimime/mytest_files/mytest.c new file mode 100644 index 000000000..ccbeddc85 --- /dev/null +++ b/main/minimime/mytest_files/mytest.c @@ -0,0 +1,71 @@ +#include <stdlib.h> +#include <stdio.h> + +#include "mm.h" + +int main(int argc, char *argv[]) +{ + const char *filename = "mytest_files/ast_postdata3"; + MM_CTX *ctx; + struct mm_mimepart *part; + struct mm_content *cont; + + int res = 0; + const char *disp; + int i; + + mm_library_init(); + mm_codec_registerdefaultcodecs(); + + printf("\nThe test should run 2 times with the same results.\n\n"); + + for (i = 0; i < 2; i++) { + printf("\nTest run #%d ...\n", i + 1); + + if (!(ctx = mm_context_new())) { + printf("Failed to create MiniMIME context!\n\n"); + break; + } + + res = mm_parse_file(ctx, filename, MM_PARSE_LOOSE, 0); + if (res == -1) { + printf("Error parsing file %s\n\n", filename); + mm_context_free(ctx); + break; + } + + res = mm_context_countparts(ctx); + if (res != 3) { + printf("This file should have 3 parts, but parser says %d\n\n", res); + res = -1; + mm_context_free(ctx); + break; + } + + /* Part 2 is the file */ + if (!(part = mm_context_getpart(ctx, 2))) { + printf("Failed to get a reference to part 2 of the MIME data\n\n"); + res = -1; + mm_context_free(ctx); + break; + } + + /* This is where the problems are demonstrated. */ + cont = mm_mimepart_getcontent(part); + + if ((disp = mm_content_getdispositiontype(cont))) + printf("SUCCESS: Got the Content-Disposition: %s\n", disp); + else + printf("FAILURE: Could not get the Content-Disposition value!\n"); + + res = mm_mimepart_getlength(part); + if (res == 1279) + printf("SUCCESS: Got the correct value for the body length: %d\n\n", res); + else + printf("FAILURE: The parser says this MIME part has %d length, but it should be 1279\n\n", res); + + mm_context_free(ctx); + } + + exit(res); +} |