From 2bb8c35ce1b37f2565a66924691cbdf9be718736 Mon Sep 17 00:00:00 2001 From: Edwin Stearns Date: Sat, 18 Feb 2012 11:35:21 -0200 Subject: [PATCH] Be nice to a server that returns its URL without a trailing slash Attached is a patch that resolved an issue I found with a server that gave its device description URI without a trailing slash (e.g. `http://127.0.0.1:5555`). (cherry picked from commit a9c24fc7f327adefc5708e4565d15d65c49224ab) --- ChangeLog | 6 ++++++ upnp/src/genlib/net/http/httpreadwrite.c | 12 +++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 881e077..6f65f5b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -255,6 +255,12 @@ Version 1.8.0 Version 1.6.16 ******************************************************************************* +2012-02-07 Edwin Stearns + + Attached is a patch that resolved an issue I found with a server that + gave its device description URI without a trailing slash (e.g. + `http://127.0.0.1:5555`). + 2012-01-04 Fabrice Fontaine Bug fix for IPv4-mapped IPv6 addresses. diff --git a/upnp/src/genlib/net/http/httpreadwrite.c b/upnp/src/genlib/net/http/httpreadwrite.c index 22d7570..fdbaa6e 100644 --- a/upnp/src/genlib/net/http/httpreadwrite.c +++ b/upnp/src/genlib/net/http/httpreadwrite.c @@ -641,11 +641,13 @@ int http_Download( IN const char *url_str, return UPNP_E_INVALID_URL; hoststr += 2; temp = strchr(hoststr, '/'); - if (temp == NULL) - return UPNP_E_INVALID_URL; - *temp = '\0'; - hostlen = strlen(hoststr); - *temp = '/'; + if (temp) { + *temp = '\0'; + hostlen = strlen(hoststr); + *temp = '/'; + } else { + hostlen = strlen(hoststr); + } UpnpPrintf(UPNP_INFO, HTTP, __FILE__, __LINE__, "HOSTNAME : %s Length : %" PRIzu "\n", hoststr, hostlen); ret_code = http_MakeMessage(&request, 1, 1,