mirror of
https://github.com/rofafor/vdr-plugin-iptv.git
synced 2023-10-10 13:37:03 +02:00
Fixed a regression introduced in HTTP protocol.
This commit is contained in:
parent
05e57802c3
commit
66ab92584b
@ -39,7 +39,7 @@ bool cIptvProtocolHttp::Connect(void)
|
|||||||
{
|
{
|
||||||
debug("cIptvProtocolHttp::Connect()\n");
|
debug("cIptvProtocolHttp::Connect()\n");
|
||||||
// Check that stream address is valid
|
// Check that stream address is valid
|
||||||
if (!isempty(streamAddr) && !isempty(streamPath)) {
|
if (!isActive && !isempty(streamAddr) && !isempty(streamPath)) {
|
||||||
// Ensure that socket is valid and connect
|
// Ensure that socket is valid and connect
|
||||||
OpenSocket(socketPort, streamAddr);
|
OpenSocket(socketPort, streamAddr);
|
||||||
if (!ConnectSocket()) {
|
if (!ConnectSocket()) {
|
||||||
@ -58,12 +58,13 @@ bool cIptvProtocolHttp::Connect(void)
|
|||||||
CloseSocket();
|
CloseSocket();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now process headers
|
// Now process headers
|
||||||
if (!ProcessHeaders()) {
|
if (!ProcessHeaders()) {
|
||||||
CloseSocket();
|
CloseSocket();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
// Update active flag
|
||||||
|
isActive = true;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -71,8 +72,12 @@ bool cIptvProtocolHttp::Connect(void)
|
|||||||
bool cIptvProtocolHttp::Disconnect(void)
|
bool cIptvProtocolHttp::Disconnect(void)
|
||||||
{
|
{
|
||||||
debug("cIptvProtocolHttp::Disconnect()\n");
|
debug("cIptvProtocolHttp::Disconnect()\n");
|
||||||
|
if (isActive) {
|
||||||
// Close the socket
|
// Close the socket
|
||||||
CloseSocket();
|
CloseSocket();
|
||||||
|
// Update active flag
|
||||||
|
isActive = false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,11 +87,12 @@ bool cIptvProtocolHttp::GetHeaderLine(char* dest, unsigned int destLen,
|
|||||||
debug("cIptvProtocolHttp::GetHeaderLine()\n");
|
debug("cIptvProtocolHttp::GetHeaderLine()\n");
|
||||||
bool linefeed = false;
|
bool linefeed = false;
|
||||||
bool newline = false;
|
bool newline = false;
|
||||||
unsigned char buf[4096];
|
char *bufptr = dest;
|
||||||
unsigned char *bufptr = buf;
|
|
||||||
memset(buf, '\0', sizeof(buf));
|
|
||||||
recvLen = 0;
|
recvLen = 0;
|
||||||
|
|
||||||
|
if (!dest)
|
||||||
|
return false;
|
||||||
|
|
||||||
while (!newline || !linefeed) {
|
while (!newline || !linefeed) {
|
||||||
// Wait 500ms for data
|
// Wait 500ms for data
|
||||||
if (ReadChar(bufptr, 500)) {
|
if (ReadChar(bufptr, 500)) {
|
||||||
@ -102,8 +108,8 @@ bool cIptvProtocolHttp::GetHeaderLine(char* dest, unsigned int destLen,
|
|||||||
++recvLen;
|
++recvLen;
|
||||||
}
|
}
|
||||||
++bufptr;
|
++bufptr;
|
||||||
// Check that buffers won't be exceeded
|
// Check that buffer won't be exceeded
|
||||||
if (recvLen >= sizeof(buf) || recvLen >= destLen) {
|
if (recvLen >= destLen) {
|
||||||
error("Header wouldn't fit into buffer\n");
|
error("Header wouldn't fit into buffer\n");
|
||||||
recvLen = 0;
|
recvLen = 0;
|
||||||
return false;
|
return false;
|
||||||
@ -114,7 +120,6 @@ bool cIptvProtocolHttp::GetHeaderLine(char* dest, unsigned int destLen,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
memcpy(dest, buf, recvLen);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
5
socket.c
5
socket.c
@ -262,7 +262,6 @@ bool cIptvTcpSocket::OpenSocket(const int Port, const char *StreamAddr)
|
|||||||
void cIptvTcpSocket::CloseSocket(void)
|
void cIptvTcpSocket::CloseSocket(void)
|
||||||
{
|
{
|
||||||
debug("cIptvTcpSocket::CloseSocket()\n");
|
debug("cIptvTcpSocket::CloseSocket()\n");
|
||||||
isActive = false;
|
|
||||||
cIptvSocket::CloseSocket();
|
cIptvSocket::CloseSocket();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,8 +286,6 @@ bool cIptvTcpSocket::ConnectSocket(void)
|
|||||||
error("Connect() failed: %s", strerror_r(retval, tmp, sizeof(tmp)));
|
error("Connect() failed: %s", strerror_r(retval, tmp, sizeof(tmp)));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Update connection flag
|
|
||||||
isActive = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -311,7 +308,7 @@ int cIptvTcpSocket::Read(unsigned char* BufferAddr, unsigned int BufferLen)
|
|||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cIptvTcpSocket::ReadChar(unsigned char* BufferAddr, unsigned int TimeoutMs)
|
bool cIptvTcpSocket::ReadChar(char* BufferAddr, unsigned int TimeoutMs)
|
||||||
{
|
{
|
||||||
//debug("cIptvTcpSocket::ReadChar()\n");
|
//debug("cIptvTcpSocket::ReadChar()\n");
|
||||||
// Error out if socket not initialized
|
// Error out if socket not initialized
|
||||||
|
2
socket.h
2
socket.h
@ -48,7 +48,7 @@ public:
|
|||||||
bool OpenSocket(const int Port, const char *StreamAddr);
|
bool OpenSocket(const int Port, const char *StreamAddr);
|
||||||
void CloseSocket(void);
|
void CloseSocket(void);
|
||||||
bool ConnectSocket(void);
|
bool ConnectSocket(void);
|
||||||
bool ReadChar(unsigned char* BufferAddr, unsigned int TimeoutMs);
|
bool ReadChar(char* BufferAddr, unsigned int TimeoutMs);
|
||||||
bool Write(const char* BufferAddr, unsigned int BufferLen);
|
bool Write(const char* BufferAddr, unsigned int BufferLen);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user