Commits (11)
......@@ -3,9 +3,9 @@
AUTOMAKE_OPTIONS = foreign
noinst_LTLIBRARIES = libicehttpp.la
noinst_HEADERS = httpp.h
noinst_HEADERS = httpp.h encoding.h
libicehttpp_la_SOURCES = httpp.c
libicehttpp_la_SOURCES = httpp.c encoding.c
libicehttpp_la_CFLAGS = @XIPH_CFLAGS@
AM_CPPFLAGS = @XIPH_CPPFLAGS@
......
This diff is collapsed.
/* encoding.h
**
** http transfer encoding library
** See RFC2616 section 3.6 for more details.
**
** Copyright (C) 2015 Philipp "ph3-der-loewe" Schafft <lion@lion.leolix.org>
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Library General Public
** License as published by the Free Software Foundation; either
** version 2 of the License, or (at your option) any later version.
**
** This library is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Library General Public License for more details.
**
** You should have received a copy of the GNU Library General Public
** License along with this library; if not, write to the
** Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
** Boston, MA 02110-1301, USA.
**
*/
#ifndef __ENCODING_H
#define __ENCODING_H
#include <sys/types.h>
/* known encodings */
#define HTTPP_ENCODING_IDENTITY "identity" /* RFC2616 */
#define HTTPP_ENCODING_CHUNKED "chunked" /* RFC2616 */
#define HTTPP_ENCODING_GZIP "gzip" /* RFC1952 */
#define HTTPP_ENCODING_COMPRESS "compress" /* ??? */
#define HTTPP_ENCODING_DEFLATE "deflate" /* RFC1950, RFC1951 */
typedef struct httpp_encoding_tag httpp_encoding_t;
typedef struct httpp_meta_tag httpp_meta_t;
struct httpp_meta_tag {
char *key;
void *value;
size_t value_len;
httpp_meta_t *next;
};
/* meta data functions */
/* meta data is to be used in a encoding-specific way */
httpp_meta_t *httpp_encoding_meta_new(const char *key, const char *value);
int httpp_encoding_meta_free(httpp_meta_t *self);
int httpp_encoding_meta_append(httpp_meta_t **dst, httpp_meta_t *next);
/* General setup */
httpp_encoding_t *httpp_encoding_new(const char *encoding);
int httpp_encoding_addref(httpp_encoding_t *self);
int httpp_encoding_release(httpp_encoding_t *self);
/* Read data from backend.
* if cb is NULL this will read from the internal buffer.
*/
ssize_t httpp_encoding_read(httpp_encoding_t *self, void *buf, size_t len, ssize_t (*cb)(void*, void*, size_t), void *userdata);
/* Read any meta data that is in buffer.
* After a call to this function the meta data is released from the
* encoding object and the caller is responsible to free it.
*/
httpp_meta_t *httpp_encoding_get_meta(httpp_encoding_t *self);
/* Write data to backend.
* If buf is NULL this will flush buffers.
* Depending on encoding flushing buffers may not be safe if not
* at end of stream.
*/
ssize_t httpp_encoding_write(httpp_encoding_t *self, const void *buf, size_t len, ssize_t (*cb)(void*, const void*, size_t), void *userdata);
/* Check if we have something to flush. */
ssize_t httpp_encoding_pending(httpp_encoding_t *self);
/* Attach meta data to the stream.
* this is to be written out as soon as the encoding supports.
*/
int httpp_encoding_append_meta(httpp_encoding_t *self, httpp_meta_t *meta);
#endif
......@@ -2,8 +2,27 @@
**
** http parsing engine
**
** This program is distributed under the GNU General Public License, version 2.
** A copy of this license is included with this source.
** Copyright (C) 2014 Michael Smith <msmith@icecast.org>,
** Ralph Giles <giles@xiph.org>,
** Ed "oddsock" Zaleski <oddsock@xiph.org>,
** Karl Heyes <karl@xiph.org>,
** Philipp "ph3-der-loewe" Schafft <lion@lion.leolix.org>
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Library General Public
** License as published by the Free Software Foundation; either
** version 2 of the License, or (at your option) any later version.
**
** This library is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Library General Public License for more details.
**
** You should have received a copy of the GNU Library General Public
** License along with this library; if not, write to the
** Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
** Boston, MA 02110-1301, USA.
**
*/
#ifdef HAVE_CONFIG_H
......@@ -22,10 +41,6 @@
#include <avl/avl.h>
#include "httpp.h"
#if defined(_WIN32) && !defined(HAVE_STRCASECMP)
#define strcasecmp stricmp
#endif
#define MAX_HEADERS 32
/* internal functions */
......@@ -383,6 +398,18 @@ int httpp_parse(http_parser_t *parser, const char *http_data, unsigned long len)
case httpp_req_head:
httpp_setvar(parser, HTTPP_VAR_REQ_TYPE, "HEAD");
break;
case httpp_req_options:
httpp_setvar(parser, HTTPP_VAR_REQ_TYPE, "OPTIONS");
break;
case httpp_req_delete:
httpp_setvar(parser, HTTPP_VAR_REQ_TYPE, "DELETE");
break;
case httpp_req_trace:
httpp_setvar(parser, HTTPP_VAR_REQ_TYPE, "TRACE");
break;
case httpp_req_connect:
httpp_setvar(parser, HTTPP_VAR_REQ_TYPE, "CONNECT");
break;
case httpp_req_source:
httpp_setvar(parser, HTTPP_VAR_REQ_TYPE, "SOURCE");
break;
......@@ -562,6 +589,14 @@ httpp_request_type_e httpp_str_to_method(const char * method) {
return httpp_req_put;
} else if (strcasecmp("HEAD", method) == 0) {
return httpp_req_head;
} else if (strcasecmp("OPTIONS", method) == 0) {
return httpp_req_options;
} else if (strcasecmp("DELETE", method) == 0) {
return httpp_req_delete;
} else if (strcasecmp("TRACE", method) == 0) {
return httpp_req_trace;
} else if (strcasecmp("CONNECT", method) == 0) {
return httpp_req_connect;
} else if (strcasecmp("SOURCE", method) == 0) {
return httpp_req_source;
} else if (strcasecmp("PLAY", method) == 0) {
......
......@@ -2,8 +2,26 @@
**
** http parsing library
**
** This program is distributed under the GNU General Public License, version 2.
** A copy of this license is included with this source.
** Copyright (C) 2014 Michael Smith <msmith@icecast.org>,
** Ralph Giles <giles@xiph.org>,
** Karl Heyes <karl@xiph.org>,
** Philipp "ph3-der-loewe" Schafft <lion@lion.leolix.org>
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Library General Public
** License as published by the Free Software Foundation; either
** version 2 of the License, or (at your option) any later version.
**
** This library is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Library General Public License for more details.
**
** You should have received a copy of the GNU Library General Public
** License along with this library; if not, write to the
** Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
** Boston, MA 02110-1301, USA.
**
*/
#ifndef __HTTPP_H
......@@ -29,6 +47,10 @@ typedef enum httpp_request_type_tag {
httpp_req_post,
httpp_req_put,
httpp_req_head,
httpp_req_options,
httpp_req_delete,
httpp_req_trace,
httpp_req_connect,
/* Icecast SOURCE, to be replaced with PUT some day */
httpp_req_source,
/* XXX: ??? */
......
/*
** Logging framework.
**
** This program is distributed under the GNU General Public License, version 2.
** A copy of this license is included with this source.
** Copyright (C) 2014 Michael Smith <msmith@icecast.org>,
** Ralph Giles <giles@xiph.org>,
** Ed "oddsock" Zaleski <oddsock@xiph.org>,
** Karl Heyes <karl@xiph.org>,
** Jack Moffitt <jack@icecast.org>,
** Philipp "ph3-der-loewe" Schafft <lion@lion.leolix.org>,
** Thomas Ruecker <thomas@ruecker.fi>
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Library General Public
** License as published by the Free Software Foundation; either
** version 2 of the License, or (at your option) any later version.
**
** This library is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Library General Public License for more details.
**
** You should have received a copy of the GNU Library General Public
** License along with this library; if not, write to the
** Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
** Boston, MA 02110-1301, USA.
**
*/
#ifdef HAVE_CONFIG_H
......
/*
** Logging framework.
**
** This program is distributed under the GNU General Public License, version 2.
** A copy of this license is included with this source.
** Copyright (C) 2014 Michael Smith <msmith@icecast.org>,
** Ralph Giles <giles@xiph.org>,
** Ed "oddsock" Zaleski <oddsock@xiph.org>,
** Karl Heyes <karl@xiph.org>,
** Jack Moffitt <jack@icecast.org>,
** Philipp "ph3-der-loewe" Schafft <lion@lion.leolix.org>,
** Thomas Ruecker <thomas@ruecker.fi>
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Library General Public
** License as published by the Free Software Foundation; either
** version 2 of the License, or (at your option) any later version.
**
** This library is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Library General Public License for more details.
**
** You should have received a copy of the GNU Library General Public
** License along with this library; if not, write to the
** Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
** Boston, MA 02110-1301, USA.
**
*/
#ifndef __LOG_H__
......
/*
* resolver.c - name resolver library
*
* Copyright (C) 1999 the icecast team <team@icecast.org>
* Copyright (C) 2014 Michael Smith <msmith@icecast.org>,
* Brendan Cully <brendan@xiph.org>,
* Karl Heyes <karl@xiph.org>,
* Jack Moffitt <jack@icecast.org>,
* Philipp "ph3-der-loewe" Schafft <lion@lion.leolix.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......@@ -14,8 +18,10 @@
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
......
/*
** resolver.h
**
** name resolver library header
**
*/
* resolver.h
*
* name resolver library header
*
* Copyright (C) 2014 Brendan Cully <brendan@xiph.org>,
* Jack Moffitt <jack@icecast.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifndef __RESOLVER_H
#define __RESOLVER_H
......
/* -*- c-basic-offset: 4; -*- */
/* sock.c: General Socket Functions
*
* Copyright (c) 1999 the icecast team
* Copyright (C) 2014 Michael Smith <msmith@icecast.org>,
* Brendan Cully <brendan@xiph.org>,
* Karl Heyes <karl@xiph.org>,
* Jack Moffitt <jack@icecast.org>,
* Ed "oddsock" Zaleski <oddsock@xiph.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......@@ -14,8 +18,10 @@
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifdef HAVE_CONFIG_H
......@@ -47,15 +53,6 @@
#include <netdb.h>
#else
#include <winsock2.h>
#define vsnprintf _vsnprintf
#define EINPROGRESS WSAEINPROGRESS
#define ENOTSOCK WSAENOTSOCK
#define EWOULDBLOCK WSAEWOULDBLOCK
#define EALREADY WSAEALREADY
#define socklen_t int
#ifndef __MINGW32__
#define va_copy(ap1, ap2) memcpy(&ap1, &ap2, sizeof(va_list))
#endif
#endif
#include "sock.h"
......@@ -156,6 +153,12 @@ int sock_recoverable(int error)
#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
case EWOULDBLOCK:
#endif
#if defined (WSAEWOULDBLOCK) && WSAEWOULDBLOCK != EWOULDBLOCK
case WSAEWOULDBLOCK:
#endif
#if defined (WSAEINPROGRESS) && WSAEINPROGRESS != EINPROGRESS
case WSAEINPROGRESS:
#endif
#ifdef ERESTART
case ERESTART:
#endif
......@@ -175,6 +178,12 @@ int sock_stalled (int error)
#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
case EWOULDBLOCK:
#endif
#if defined (WSAEWOULDBLOCK) && WSAEWOULDBLOCK != EWOULDBLOCK
case WSAEWOULDBLOCK:
#endif
#if defined (WSAEINPROGRESS) && WSAEINPROGRESS != EINPROGRESS
case WSAEINPROGRESS:
#endif
#ifdef ERESTART
case ERESTART:
#endif
......
/* sock.h
* - General Socket Function Headers
*
* Copyright (c) 1999 the icecast team
* Copyright (C) 2014 Michael Smith <msmith@icecast.org>,
* Brendan Cully <brendan@xiph.org>,
* Karl Heyes <karl@xiph.org>,
* Jack Moffitt <jack@icecast.org>,
* Ed "oddsock" Zaleski <oddsock@xiph.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
......
/* threads.c: Thread Abstraction Functions
*
* Copyright (c) 1999, 2000 the icecast team <team@icecast.org>
* Copyright (C) 2014 Michael Smith <msmith@icecast.org>,
* Brendan Cully <brendan@xiph.org>,
* Karl Heyes <karl@xiph.org>,
* Jack Moffitt <jack@icecast.org>,
* Ed "oddsock" Zaleski <oddsock@xiph.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......@@ -13,8 +17,10 @@
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifdef HAVE_CONFIG_H
......@@ -264,7 +270,6 @@ static void _catch_signals(void)
thread_type *thread_create_c(char *name, void *(*start_routine)(void *),
void *arg, int detached, int line, char *file)
{
int ok = 1;
thread_type *thread = NULL;
thread_start_t *start = NULL;
pthread_attr_t attr;
......
/* thread.h
* - Thread Abstraction Function Headers
*
* Copyright (c) 1999, 2000 the icecast team <team@icecast.org>
* Copyright (C) 2014 Michael Smith <msmith@icecast.org>,
* Brendan Cully <brendan@xiph.org>,
* Karl Heyes <karl@xiph.org>,
* Jack Moffitt <jack@icecast.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......@@ -14,8 +17,10 @@
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifndef __THREAD_H__
......
/* timing.c
** - Timing functions
**
** This program is distributed under the GNU General Public License, version 2.
** A copy of this license is included with this source.
*/
* - Timing functions
*
* Copyright (C) 2014 Michael Smith <msmith@icecast.org>,
* Brendan Cully <brendan@xiph.org>,
* Karl Heyes <karl@xiph.org>,
* Jack Moffitt <jack@icecast.org>,
* Ed "oddsock" Zaleski <oddsock@xiph.org>,
* Ralph Giles <giles@xiph.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
......
/*
** Timing functions.
**
** This program is distributed under the GNU General Public License, version 2.
** A copy of this license is included with this source.
*/
* Timing functions.
*
* Copyright (C) 2014 Michael Smith <msmith@icecast.org>,
* Karl Heyes <karl@xiph.org>,
* Jack Moffitt <jack@icecast.org>,
* Moritz Grimm <mdgrimm@gmx.net>,
* Ralph Giles <giles@xiph.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifndef __TIMING_H__
#define __TIMING_H__
......