aboutsummaryrefslogtreecommitdiffstats
path: root/src/inputStream_http.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* core rewrite (decode,player,outputBuffer,playlist)Eric Wong2008-08-161-4/+4
| | | | | | | | | | | | | This is a huge refactoring of the core mpd process. The queueing/buffering mechanism is heavily reworked. The player.c code has been merged into outputBuffer (the actual ring buffering logic is handled by ringbuf.c); and decode.c actually handles decoding stuff. The end result is several hundreds of lines shorter, even though we still have a lot of DEBUG statements left in there for tracing and a lot of assertions, too.
* http: hopefully allow seeking to work on static filesEric Wong2008-06-301-1/+2
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@7398 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* introduce struct condition as a more correct version of NotifyEric Wong2008-06-301-64/+29
| | | | | Start using it in the HTTP code git-svn-id: https://svn.musicpd.org/mpd/trunk@7395 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* http: initial rewrite using ringbuffer + pthreadsEric Wong2008-06-301-556/+793
| | | | | | | | | | | | | | | | | This institutes the usage of a separate thread to buffer HTTP input. It is basically practice code for using the ringbuffer code which I plan on reusing for the OutputBuffer as well as further input buffering for disk (networked filesystems over WAN, laptops on battery, etc). Each readFromInputStream() call on an HTTP stream can take several seconds to complete, short reads are avoided. A single-threaded solution for systems supporting large enough SO_RCVBUF values should also be possible and will likely be done in the future; but this lock-free(except when full/empty) ringbuffer is cool :) git-svn-id: https://svn.musicpd.org/mpd/trunk@7393 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* http: fix some small memory leaks when hitting redirectsEric Wong2008-06-301-0/+6
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@7392 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* http: split out logic around getaddrinfo() and connect()Eric Wong2008-06-301-40/+42
| | | | | Makes code easier to read and modularize git-svn-id: https://svn.musicpd.org/mpd/trunk@7388 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* http: split out auth code since it's mostly uninteresting for nowEric Wong2008-06-301-75/+1
| | | | | | The auth code also has some ugly usages of string generation which I will eventually replace with something nicer... git-svn-id: https://svn.musicpd.org/mpd/trunk@7387 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* fix several errors/warnings which only appear with -O3Max Kellermann2008-04-121-1/+1
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@7333 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* notify: cleanupsEric Wong2008-03-261-3/+2
| | | | | | | | * move set_nonblock{,ing}() into utils.c since we use it elsewhere, too * add proper error checking to set_nonblocking() * use os_compat.h instead of individually #includ-ing system headers git-svn-id: https://svn.musicpd.org/mpd/trunk@7217 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* networking: more assertions and cleanups to size_t/unsigned changesEric Wong2008-03-261-31/+33
| | | | | | | | | | | | Basically, I don't trust myself nor Max to not have bugs in our code when switching over to unsigned types, so I've added more assertions which will hopefully trip and force us to fix these bugs before somebody can exploit them :) Some cleanups for parameter parsing using strtol and error reporting to the user. Also, fix some completely garbled indentation in inputStream_http.c git-svn-id: https://svn.musicpd.org/mpd/trunk@7209 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* use size_tMax Kellermann2008-03-261-19/+18
| | | | | | | | When dealing with in-memory lengths, the standard type "size_t" should be used. Missing one can be quite dangerous, because an attacker could provoke an integer under-/overflow, which may provide an attack vector. git-svn-id: https://svn.musicpd.org/mpd/trunk@7205 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* fix -Wconst warningsMax Kellermann2008-02-051-1/+2
| | | | | | [ew: cleaned up the dirty union hack a bit] Signed-off-by: Eric Wong <normalperson@yhbt.net> git-svn-id: https://svn.musicpd.org/mpd/trunk@7180 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Cleanup #includes of standard system headers and put them in one placeEric Wong2008-01-031-14/+1
| | | | | | | | | | | | | This will make refactoring features easier, especially now that pthreads support and larger refactorings are on the horizon. Hopefully, this will make porting to other platforms (even non-UNIX-like ones for masochists) easier, too. os_compat.h will house all the #includes for system headers considered to be the "core" of MPD. Headers for optional features will be left to individual source files. git-svn-id: https://svn.musicpd.org/mpd/trunk@7130 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Re-enable seeking in http streams.Qball Cow2007-11-281-1/+1
| | | | | | Fixing stopping mpd from block when trying to stop a ogg stream that is buffering. git-svn-id: https://svn.musicpd.org/mpd/trunk@7053 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Don't try to forever to get data when the sockets winds up in "temporaryQball Cow2007-11-281-8/+21
| | | | | | | | unavailable" when streaming music. But give up after 100 times. This is atm better then waiting until the connection gets back, because mpd blocks on this. git-svn-id: https://svn.musicpd.org/mpd/trunk@7052 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Disable seeking on streams, because of bug 1611. When playing ogg, the ↵Qball Cow2007-11-181-1/+1
| | | | | decoder seeks through the file then starts to play. This does not mix well with streams from websites. Stopping playback of an oggstream that is trying to stream will result in mpd hanging. git-svn-id: https://svn.musicpd.org/mpd/trunk@7039 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* inputStream_http: signal the server to close after all requestsEric Wong2007-09-081-1/+1
| | | | | | | | | | | | | | We want the partial content goodies of HTTP/1.1 without requiring persistent connections. Persistent connections across multiple HTTP requests don't really help in the case of MPD, either, because our content is usually big and heavy. Note: this puts MPD at the hands of the server to correctly close() the TCP connection we're using. If we connect to a rogue server that keeps the connection alive even when request not to, we'll spin :( However, encountering such a server is very unlikely... git-svn-id: https://svn.musicpd.org/mpd/trunk@6867 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* adding \n to a bunch of error message stringsJ. Alexander Treuman2007-08-271-1/+1
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@6826 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Use string concatenation instead of snprintf for the User-Agent HTTPJ. Alexander Treuman2007-06-091-2/+1
| | | | | header. git-svn-id: https://svn.musicpd.org/mpd/trunk@6520 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Tidying up some code.J. Alexander Treuman2007-06-091-12/+14
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@6519 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Use strncasecmp instead of strncmp when comparing HTTP headers. It seemsJ. Alexander Treuman2007-06-041-6/+6
| | | | | | | some versions of shoutcast send "content-type" in all lowercase, and I don't trust other servers to get the case right for the rest of the headers we look for. git-svn-id: https://svn.musicpd.org/mpd/trunk@6482 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Removing that space that was recently added to the "Icy-Metadata: 1" HTTPJ. Alexander Treuman2007-06-031-1/+1
| | | | | | | | header. While this is odd for an HTTP header, it's actually quite common for streaming clients to send it without a space. Some clients do send with a space as well, but without one has always worked fine and may in fact be more compatible. git-svn-id: https://svn.musicpd.org/mpd/trunk@6472 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Removing some commented code that wrote HTTP streams to stdout.J. Alexander Treuman2007-06-021-4/+0
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@6461 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Someone forgot a space in the "Icy-Metadata: 1" HTTP header.J. Alexander Treuman2007-06-021-1/+1
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@6452 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Changing all calls to ERROR() followed by exit(EXIT_FAILURE) with a singleJ. Alexander Treuman2007-05-261-16/+8
| | | | | call to FATAL(). git-svn-id: https://svn.musicpd.org/mpd/trunk@6276 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* The massive copyright updateAvuton Olrich2007-04-051-1/+1
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@5834 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* inputStream_http: cleanup GET request code (finishHTTPInit)Eric Wong2007-02-191-29/+29
| | | | | | | | | | | | | | | | | Avoid unnecessary memset to zero, snprintf always puts a trailing '\0'. We also have no need to subtract one from the buffer we're snprintf-ing it to. We also check the return value of snprintf to ensure it's not too long. I have a feeling we might as well avoid snprintf altogether so we don't have to worry about buffer sizing/stack overflow and just do a bunch of write(2)s, letting Nagle sort it out... Also, centralize some of the exit error handling in with goto. This makes the code a bit more consistent and maintainable as well as reducing code and binary size. git-svn-id: https://svn.musicpd.org/mpd/trunk@5395 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* inputStream_http: fix HTTP seekingEric Wong2007-02-191-1/+1
| | | | | | | | We need to identify ourselves as HTTP/1.1 so Range: works; and so the server can return HTTP/1.1 instead of HTTP/1.0. Tested against lighttpd 1.4.13 git-svn-id: https://svn.musicpd.org/mpd/trunk@5394 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Fix a bug where mpd would complain about a proxy password being specifiedJ. Alexander Treuman2007-02-061-7/+7
| | | | | and not a proxy user even when both are specified. git-svn-id: https://svn.musicpd.org/mpd/trunk@5324 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Don't initialize globals to zero (or NULL)Eric Wong2007-01-141-4/+4
| | | | | | | | Some compilers and linkers aren't smart enough to optimize this, as global variables are implictly initialized to zero. As a result, binaries are a bit smaller as more goes in the .bss and less in the text section. git-svn-id: https://svn.musicpd.org/mpd/trunk@5254 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* inputStream_http: stop mixing declarations with codeEric Wong2007-01-141-1/+3
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@5242 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Adding support for seeking HTTP streams.J. Alexander Treuman2006-12-231-17/+24
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@5159 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Replace strdup and {c,re,m}alloc with x* variants to check for OOM errorsEric Wong2006-08-261-20/+20
| | | | | | | | | | | | | | | | | | | I'm checking for zero-size allocations and assert()-ing them, so we can more easily get backtraces and debug problems, but we'll also allow -DNDEBUG people to live on the edge if they wish. We do not rely on errno when checking for OOM errors because some implementations of malloc do not set it, and malloc is commonly overridden by userspace wrappers. I've spent some time looking through the source and didn't find any obvious places where we would explicitly allocate 0 bytes, so we shouldn't trip any of those assertions. We also avoid allocating zero bytes because C libraries don't handle this consistently (some return NULL, some not); and it's dangerous either way. git-svn-id: https://svn.musicpd.org/mpd/trunk@4690 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* remove clumsy strncpy useEric Wong2006-07-301-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | strncpy isn't really safe because it doesn't guarantee null termination, and we have had to work around it in several places. strlcpy (from OpenBSD) isn't great, either because it often leaves errors going unchecked (by truncating strings). So we'll add the pathcpy_trunc() function with is basically strlcpy with a hardcoded MAXPATHLEN as the limit, and we'll acknowledge truncation since we only work on paths and MAXPATHLEN should be set correctly by the system headers[1]. file-specific notes: inputStream_http: eyeballing the changes here, it seems to look alright but I haven't actually tested it myself. ls: don't even bother printing a file if the filename is too long (and when is it ever?) since we won't be able to read it anyways. metadataChunk: it's only metadata, and it's only for showin the user, so truncating it here souldn't be a big issue. memset to zero in init is unecessary, so lets not waste cycles [1] - If the system headers are screwed up, then we're majorly screwed regardless of what we do :x git-svn-id: https://svn.musicpd.org/mpd/trunk@4491 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Add mpd-indent.shAvuton Olrich2006-07-201-3/+3
| | | | | | Add a few new options for indent to try to make things a bit cleaner git-svn-id: https://svn.musicpd.org/mpd/trunk@4411 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Add mpd-indent.shAvuton Olrich2006-07-201-559/+589
| | | | | | Indent the entire tree, hopefully we can keep it indented. git-svn-id: https://svn.musicpd.org/mpd/trunk@4410 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* sparse: ANSI-fy function declarationsEric Wong2006-07-171-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These are just warnings from sparse, but it makes the output easier to read. I ran this through a quick perl script, but of course verified the output by looking at the diff and making sure the thing still compiles. here's the quick perl script I wrote to generate this patch: ----------- 8< ----------- use Tie::File; defined(my $pid = open my $fh, '-|') or die $!; if (!$pid) { open STDERR, '>&STDOUT' or die $!; exec 'sparse', @ARGV or die $!; } my $na = 'warning: non-ANSI function declaration of function'; while (<$fh>) { print STDERR $_; if (/^(.+?\.[ch]):(\d+):(\d+): $na '(\w+)'/o) { my ($f, $l, $pos, $func) = ($1, $2, $3, $4); $l--; tie my @x, 'Tie::File', $f or die "$!: $f"; print '-', $x[$l], "\n"; $x[$l] =~ s/\b($func\s*)\(\s*\)/$1(void)/; print '+', $x[$l], "\n"; untie @x; } } git-svn-id: https://svn.musicpd.org/mpd/trunk@4378 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Change shank's email addressJ. Alexander Treuman2006-07-141-1/+1
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@4333 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Huge header update, update the copyright and addAvuton Olrich2006-07-131-1/+1
| | | | | the GPL header where necessary git-svn-id: https://svn.musicpd.org/mpd/trunk@4317 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* inputStream_http: avoid printf, use our handy macros in log.hEric Wong2006-05-211-1/+1
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@4210 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* Applied a modified patch for bug 344, needs testing with ipv6Qball Cow2006-05-141-83/+69
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@4171 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* merge with mpd/trunk up to r3925Eric Wong2006-03-161-0/+14
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@3926 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* inputStream_http.c: speling fikcsesEric Wong2006-03-151-4/+4
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@3921 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* fix some parsing of http_prebuffer_sizeWarren Dukes2005-04-171-3/+3
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@3216 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* change the http identification string to package_name/package_versionWarren Dukes2005-01-231-1/+4
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@2896 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* fix oss_openDevice() to match the new openDevice callback protocol (w/o a ↵Warren Dukes2004-11-201-1/+2
| | | | | audioFormat argument) git-svn-id: https://svn.musicpd.org/mpd/trunk@2715 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* not too smart shank, forgetting to set default buffer sizes in inputStream_httpWarren Dukes2004-11-051-2/+2
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@2513 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* make http buffer and prebuffer size configurableWarren Dukes2004-11-021-10/+51
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@2479 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* merge shank-rewrite-config changesWarren Dukes2004-10-281-48/+60
| | | git-svn-id: https://svn.musicpd.org/mpd/trunk@2375 09075e82-0dd4-0310-85a5-a0d7c8717e4f
* fix segfault when reconnecting to icecast server, this was due to error ↵Warren Dukes2004-10-261-1/+0
| | | | | sending metadata and not checking afterward if connection is open still git-svn-id: https://svn.musicpd.org/mpd/trunk@2349 09075e82-0dd4-0310-85a5-a0d7c8717e4f