summaryrefslogtreecommitdiff
path: root/main/http.c
AgeCommit message (Collapse)Author
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
2006-10-21the default port number was erroneously stored in host order,Luigi Rizzo
and reading from the config file used ntohs instead of htons. this ought to be merged to 1.4 as well. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45836 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-18introduce uri_decode() so that '+' are translated into ' 'Luigi Rizzo
(e.g. browsers do this when they encode input strings from a form). git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45474 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-18various code simplifications to reduce nesting depth,Luigi Rizzo
minor optimizations to avoid extra calls of strlen(), and some variable localization. One feature worth backporting is the move of ast_variables_destroy() to a different place in handle_uri() to avoid leaking memory in case a uri is not found. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45463 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-16comment some functions, and more small code simplificationsLuigi Rizzo
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45169 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-16fix indentation of a large block after changes in previous commitLuigi Rizzo
(basically whitespace only). git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45161 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-16simplify string parsing routines using ast_skip_*() functions.Luigi Rizzo
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45160 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-15don't forget to close a descriptor on a malloc failure.Luigi Rizzo
On passing, small rearrangement of the code to reduce indentation. There is a bit more cleanup planned for this file, so a merge to 1.4 will be done when it is all done. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45152 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-15typo: serer -> serverLuigi Rizzo
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45151 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-06make sure sockets are blocking when they should be blocking.Luigi Rizzo
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@44568 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-04Merged revisions 44378 via svnmerge from Kevin P. Fleming
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r44378 | kpfleming | 2006-10-04 14:47:22 -0500 (Wed, 04 Oct 2006) | 4 lines update thread creation code a bit reduce standard thread stack size slightly to allow the pthreads library to allocate the stack+data and not overflow a power-of-2 allocation in the kernel and waste memory/address space add a new stack size for 'background' threads (those that don't handle PBX calls) when LOW_MEMORY is defined ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@44379 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-03bug #8076 check option_debug before printing to debug channel.Matt O'Gorman
patch provided in bugnote, with minor changes. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@44253 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-09-21Remove deprecated CLI apps from the coreTilghman Lesher
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@43449 65c4cc65-6c06-0410-ace0-fbb531ad65f3