Commit 06339a5e authored by Frédéric Yhuel's avatar Frédéric Yhuel Committed by Hugo Beauzée-Luyssen

DASH: fix URL parsing

use vlc_UrlParse() instead of home made code and handle the case where
the port is not equal to 80.
Signed-off-by: default avatarHugo Beauzée-Luyssen <beauze.h@gmail.com>
parent 21d55988
......@@ -26,6 +26,7 @@
#endif
#include "HTTPConnection.h"
#include <vlc_url.h>
using namespace dash::http;
......@@ -74,22 +75,15 @@ int HTTPConnection::peek (const uint8_t **pp_peek, size_t
}
void HTTPConnection::parseURL ()
{
vlc_url_t url_components;
vlc_UrlParse(&url_components, this->url.c_str(), 0);
this->path = url_components.psz_path;
this->port = url_components.i_port ? url_components.i_port : 80;
if(this->url.compare(0, 4, "http"))
{
this->hostname = Helper::combinePaths(Helper::getDirectoryPath(stream->psz_path), this->url);
}
else
{
this->hostname = this->url;
this->hostname.erase(0, 7);
}
this->path = this->hostname;
size_t pos = this->hostname.find("/");
this->hostname = this->hostname.substr(0, pos);
this->path = this->path.substr(pos, this->path.size());
this->hostname = url_components.psz_host;
this->request = "GET " + this->path + " HTTP/1.1\r\n" +
"Host: " + this->hostname + "\r\nConnection: close\r\n\r\n";
......@@ -118,7 +112,7 @@ bool HTTPConnection::init ()
this->parseURL();
this->prepareRequest();
this->httpSocket = net_ConnectTCP(this->stream, this->hostname.c_str(), 80);
this->httpSocket = net_ConnectTCP(this->stream, this->hostname.c_str(), this->port);
if(this->sendData(this->request))
return this->parseHeader();
......
......@@ -62,6 +62,7 @@ namespace dash
std::string url;
std::string hostname;
std::string path;
int port;
std::string request;
stream_t *stream;
Chunk *chunk;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment