summaryrefslogtreecommitdiff
path: root/main/http.c
AgeCommit message (Collapse)Author
2007-11-24remove some unnecessary includesLuigi Rizzo
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89542 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-21remove a bunch of useless #include "options.h"Luigi Rizzo
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89511 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-20move asterisk/paths.h outside asterisk.h and into those filesLuigi Rizzo
who really need it. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89466 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-19another bunch of include removals (errno.h and asterisk/logger.h)Luigi Rizzo
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89425 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-17trim more redundant headersLuigi Rizzo
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89384 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-11-16Start untangling header inclusion in a way that does not affectLuigi Rizzo
build times - tested, there is no measureable difference before and after this commit. In this change: use asterisk/compat.h to include a small set of system headers: inttypes.h, unistd.h, stddef.h, stddint.h, sys/types.h, stdarg.h, stdlib.h, alloca.h, stdio.h Where available, the inclusion is conditional on HAVE_FOO_H as determined by autoconf. Normally, source files should not include any of the above system headers, and instead use either "asterisk.h" or "asterisk/compat.h" which does it better. For the time being I have left alone second-level directories (main/db1-ast, etc.). git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89333 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-10-22Switch from AST_CLI (formerly NEW_CLI) to AST_CLI_DEFINE, since the former ↵Jason Parker
didn't make much sense git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@86820 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-10-19Convert NEW_CLI to AST_CLI.Jason Parker
Closes issue #11039, as suggested by seanbright. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@86536 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-09-18(issue #10724)Jason Parker
Reported by: eliel Patches: res_features.c.patch uploaded by eliel (license 64) res_agi.c.patch uploaded by seanbright (license 71) res_musiconhold.c.patch uploaded by seanbright (license 71) pbx.c.patch uploaded by moy (license 222) logger.c.patch uploaded by moy (license 222) frame.c.patch uploaded by moy (license 222) manager.c.patch uploaded by moy (license 222) http.c.patch uploaded by moy (license 222) dnsmgr.c.patch uploaded by moy (license 222) res_realtime.c.patch uploaded by eliel (license 64) res_odbc.c.patch uploaded by seanbright (license 71) res_jabber.c.patch uploaded by eliel (license 64) chan_local.c.patch uploaded by eliel (license 64) chan_agent.c.patch uploaded by eliel (license 64) chan_alsa.c.patch uploaded by eliel (license 64) chan_features.c.patch uploaded by eliel (license 64) chan_sip.c.patch uploaded by eliel (license 64) RollUp.1.patch (includes all of the above patches) uploaded by seanbright (license 71) Convert many CLI commands to the NEW_CLI format. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@82930 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-09-17Fix memory leak introduced when POST support was added.Doug Bailey
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@82568 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-08-29This code was in team/murf/bug8684-trunk; it should fix bug 8684 in trunk. I ↵Steve Murphy
didn't add it to 1.4 yet, because it's not entirely clear to me if this is a bug fix or an enhancement. A lot of files were affected by small changes like ast_variable_new getting an added arg, for the file name the var was defined in; ast_category_new gets added args of filename and lineno; ast_category and ast_variable structures now record file and lineno for each entry; a list of all #include and #execs in a config file (or any of its inclusions are now kept in the ast_config struct; at save time, each entry is put back into its proper file of origin, in order. #include and #exec directives are folded in properly. Headers indicating that the file was generated, are generated also for each included file. Some changes to main/manager.c to take care of file renaming, via the UpdateConfig command. Multiple inclusions of the same file are handled by exploding these into multiple include files, uniquely named. There's probably more, but I can't remember it right now. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@81361 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-08-16Don't reload a configuration file if nothing has changed.Tilghman Lesher
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@79747 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-18Merge in ast_strftime branch, which changes timestamps to be accurate to the ↵Tilghman Lesher
microsecond, instead of only to the second git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@75706 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-06-29Fix my recent change for sending large files via the http server. This codeRussell Bryant
*must* write the file to the FILE *, and not the raw fd. Otherwise, it breaks TLS support. Thanks to rizzo for catching this! git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@72738 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-06-29Merge changes from team/russell/http_filetxferRussell Bryant
Handle transferring large files from the built-in http server. Previously, the code attempted to malloc a block as large as the file itself. Now it uses the sendfile() system call so that the file isn't copied into userspace at all if it is available. Otherwise, it just uses a read/write of small chunks at a time. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@72701 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-06-24Conversions to ast_debug()Russell Bryant
(issue #9984, patches from eliel and dimas) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@71338 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-06-20Revert the change made in revision 45474, since this causes other issues.Jason Parker
Issue 10021. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@70493 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-06-14Convert uses of strdup() to ast_strdup()Russell Bryant
(issue #9983, eliel) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@69436 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-06-06Issue 9869 - replace malloc and memset with ast_calloc, and other coding ↵Tilghman Lesher
guidelines changes git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@67864 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-05-24Add a new API call for creating detached threads. Then, go replace all of theRussell Bryant
places in the code where the same block of code for creating detached threads was replicated. (patch from bbryant) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@65968 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-04-30Merged revisions 62414 via svnmerge from Russell Bryant
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r62414 | russell | 2007-04-30 10:25:31 -0500 (Mon, 30 Apr 2007) | 4 lines When serving dynamic content, include a Cache-Control header to instruct the browsers to not store the resulting content. (issue #9621, reported by Pari, patch by me) ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@62415 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-04-11Merged revisions 61407 via svnmerge from Russell Bryant
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r61407 | russell | 2007-04-11 09:48:01 -0500 (Wed, 11 Apr 2007) | 4 lines Add "svgz" to the mimetypes table. (issue #9510, bkruse) In passing, constify the elements of the mimetypes table. ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@61410 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-04-08Merged revisions 60712 via svnmerge from Tilghman Lesher
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r60712 | tilghman | 2007-04-08 09:12:00 -0500 (Sun, 08 Apr 2007) | 2 lines Fix --enable-dev-mode ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@60714 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-04-06Merged revisions 60603 via svnmerge from Russell Bryant
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
2007-04-05Merged revisions 60265 via svnmerge from Russell Bryant
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r60265 | russell | 2007-04-05 10:47:17 -0500 (Thu, 05 Apr 2007) | 2 lines Add the MIME type for gif by request from Pari ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@60266 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-03-21Merged revisions 59089 via svnmerge from Joshua Colp
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r59089 | file | 2007-03-21 14:08:57 -0400 (Wed, 21 Mar 2007) | 2 lines Add svg mimetype for pari. ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@59090 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-03-08Merged revisions 58354 via svnmerge from Kevin P. Fleming
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r58354 | kpfleming | 2007-03-08 08:23:46 -0500 (Thu, 08 Mar 2007) | 2 lines this change was not needed; fclose() handles closing the file descriptor already ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@58355 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-03-08Merged revisions 58351-58352 via svnmerge from Kevin P. Fleming
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r58351 | kpfleming | 2007-03-08 08:17:17 -0500 (Thu, 08 Mar 2007) | 2 lines fix two cases where HTTP session file descriptors would not be closed ........ r58352 | kpfleming | 2007-03-08 08:17:42 -0500 (Thu, 08 Mar 2007) | 2 lines fix a compiler warning, and overwriting 'res' value ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@58353 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-02-20Merged revisions 55634 via svnmerge from Russell Bryant
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r55634 | russell | 2007-02-20 14:26:06 -0600 (Tue, 20 Feb 2007) | 3 lines Add the Asterisk version information to the Server header in HTTP responses. (requested by Pari) ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@55635 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-01-31Merged revisions 53046 via svnmerge from Russell Bryant
https://origsvn.digium.com/svn/asterisk/branches/1.4 ................ r53046 | russell | 2007-01-31 15:32:08 -0600 (Wed, 31 Jan 2007) | 11 lines Merged revisions 53045 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.2 ........ r53045 | russell | 2007-01-31 15:25:11 -0600 (Wed, 31 Jan 2007) | 3 lines Fix a bunch of places where pthread_attr_init() was called, but pthread_attr_destroy() was not. ........ ................ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@53047 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-01-24Doxygen updatesOlle Johansson
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@51932 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-12-28Convert uri_redirects list to read/write locks.Joshua Colp
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@49027 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-12-28Merged revisions 49024 via svnmerge from Joshua Colp
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r49024 | qwell | 2006-12-28 14:52:46 -0500 (Thu, 28 Dec 2006) | 2 lines make the uris_lock a rwlock instead of a mutex lock - needs to be forward ported to trunk ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@49026 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-12-27Merged revisions 49006 via svnmerge from Kevin P. Fleming
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r49006 | kpfleming | 2006-12-27 16:06:56 -0600 (Wed, 27 Dec 2006) | 2 lines since these variables all have static duration, none of them need initializers (they default to zero anyway) ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@49008 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-12-24Use spaces as a separator for the redirect option to improve readabilityRussell Bryant
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@48947 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-12-24Simplify the definition of http_uri_redirect such that only one allocation isRussell Bryant
done for exactly how much memory is needed. This was suggested by Luigi on the asterisk-dev mailing list. Thanks! git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@48933 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-12-23- Convert the list of URI handlers to use the linked list macros. While doingRussell Bryant
this, implementing locking of this list to make it thread-safe. - Add a "redirect" option to http.conf that allows redirecting one URI to another. I was inspired to do this while playing with the Asterisk GUI. I got tired of typing this URL to get to the GUI: http://localhost:8088/asterisk/static/config/cfgadvanced.html So, now I have the following line in http.conf: redirect=/=/asterisk/static/config/cfgadvanced.html Now, I can type the following into my browser and go to the GUI: http://localhost:8088 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@48930 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-12-16replace ast_build_string() with ast_str_*() functions.Luigi Rizzo
This makes the code easier to follow and saves some copies to intermediate buffers. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@48515 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-12-07- Generalize the function ssl_setup() so that the certificate infoLuigi Rizzo
are passed as an argument. - Update the code in main/http.c to use the new interface (the diff is large but mostly mechanical, due to the name change of several variables); - And since now it is trivial, implement "AMI over TLS", and document the possible options in manager.conf - And since the test client (openssl s_client -connect host:port ) does not generate \r\n as a line terminator, make get_input() also accept just a \n as a line terminator (Mac users: do you also need the \r-only version ?) The option parsing in manager.conf is not very efficient, and needs to be cleaned up and made similar to what we have in http.conf git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@48351 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-12-06Make externally visible some generic code useful to createLuigi Rizzo
and implement services over tcp and/or tcp-tls. This commit is nothing more than moving structure definitions (and documentation) from main/http.c to include/asterisk/http.h (temporary location until we find a better place), and removing the 'static' qualifier from server_root() and server_start(). The name change (adding the ast_ prefix as a minimum, and then possibly a more meaningful name) is postponed to future commits. Does not apply to other versions of asterisk. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@48324 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-11-28In the previous commit i forgot to set the poll_timeout to -1,Luigi Rizzo
causing the http threads to do busy waiting around the socket... Fix the mistake, sorry for the inconvenience! git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@48074 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-11-27document the support for running a server on TCP/TLS andLuigi Rizzo
opening an SSL socket. We are almost ready to make this code available to other modules. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@48073 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-11-27add a new http.conf option, sslbindaddr.Luigi Rizzo
Because https is more secure than http, it usually makes sense to keep this service more open than the one on the unencrypted port. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@48071 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-11-27in the helper thread, separate the FILE * creation from the actualLuigi Rizzo
function doing work on the socket. This is another generalization to provide a generic mechanism to open TCP/TLS socket with a thread managing the accpet and children threads managing the individual sessions. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@48067 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-11-27staticize a global variable and remove an unused field structure.Luigi Rizzo
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@48062 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-11-25generalize a bit the functions used to create an tcp socketLuigi Rizzo
and then run a service on it. The code in manager.c does essentially the same things, so we will be able to reuse the code in here (probably moving it to netsock.c or another appropriate library file). git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@48008 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-11-02Merged revisions 47051 via svnmerge from Tilghman Lesher
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r47051 | tilghman | 2006-11-02 17:00:20 -0600 (Thu, 02 Nov 2006) | 2 lines Reverse change of "show" to "list" and make several other commands more consistent with "category verb arguments" ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@47052 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-22Fix a few issues in the previous (disabled) HTTPS code,Luigi Rizzo
and support linux as well (using fopencookie(), which should be available in glibc). Update configure.ac to check for funopen (BSD) and fopencookie(glibc), and while we are at it also for gethostbyname_r (the generated files need to be updated, or you need to run bootstrap.sh yourself). Document the new options in http.conf.sample (names are only tentative, better ones are welcome). At this point we can safely enable the option. Anyone willing to try this on Sun and Apple platforms ? git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45892 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-22Implement https support.Luigi Rizzo
The changes are not large. Most of the diff comes from putting the global variables describing an accept session into a structure, so we can reuse the existing code for running multiple accept threads on different ports. Once this is done, and if your system has the funopen() library function (and ssl, of course), it is just a matter of calling the appropriate functions to set up the ssl connection on the existing socket, and everything works on the secure channel now. At the moment, the code is disabled because i have not implemented yet the autoconf code to detect the presence of funopen(), and add -lssl to main/Makefile if ssl libraries are present. And a bit of documentation on the http.conf arguments, too. If you want to manually enable https support, that is very simple (step 0 1 2 will be eventually detected by ./configure, the rest is something you will have to do anyways). 0. make sure your system has funopen(3). FreeBSD does, linux probably does too, not sure about other systems. 1. uncomment the following line in main/http.c // #define DO_SSL /* comment in/out if you want to support ssl */ 2. add -lssl to AST_LIBS in main/Makefile 3. add the following options to http.conf sslenable=yes sslbindport=4433 ; pick one you like sslcert=/tmp/foo.pem ; path to your certificate file. 4. generate a suitable certificate e.g. (example from mini_httpd's Makefile: openssl req -new -x509 -days 365 -nodes -out /tmp/foo.pem -keyout /tmp/foo.pem and here you go: https://localhost:4433/asterisk/manager now works. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45869 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-22it is useless and possibly wrong to use ast_cli() to send theLuigi Rizzo
reply back to http clients. Use fprintf/fwrite instead, since we are already using a FILE * to read the input. If you wonder why, this is because it makes it trivial to implement https support (as long as your system has funopen()). And this is what i am going to put in with the next few commits... git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45858 65c4cc65-6c06-0410-ace0-fbb531ad65f3