MikeL's FreeBSD howto - Fix streamripper

[20220613]
I recently needed to "fix" an open-source program that I've used forever. I've traditionally installed it via pkg manager, but needed to get at the source. Easiest way to do this is to install the port, make the changes and install from there. Bear in mind that it is typically undesirable to mix pkg's and ports, but sometime that's just what you've got to do. Of course I hadn't bothered to install the ports collection at system install time, so start by going to Install Ports Collection.

su [pswd]
If you already have an unfixed pkg version installed:
pkg delete streamripper
(If you forget this, somewhere down the line you may get an error like this):
===> streamripper-1.64.6_7 pkg(8) must be version 1.17.2 or greater, but you have 1.16.3. You must upgrade the ports-mgmt/pkg port first.
*** Error code 1

pkg upgrade streamripper
cd /usr/ports/audio/streamripper/
./configure
make
cd work/streamripper-1.64.6
edit lib/http.c
Search for "1.1". You'll find two near-identical adjacent blocks, the first says "HTTP/1.0", the latter says "HTTP/1.". This is an snprintf() in the function http_construct_sc_request(). The upper "1.0" block is commented out with the line
#ifdefined (commentout) Move this line to immediatley before the second block, and move the corresponding
#endif
to immediately after the second block.
Save changes, quit editor.
File will look like this:
change fromchange to
#if defined (commentout)
/* This is the old header */
snprintf(buffer, MAX_HEADER_LEN + MAX_HOST_LEN + SR_MAX_PATH,
"GET %s HTTP/1.0\r\n"
"Host: %s:%d\r\n"
"User-Agent: %s\r\n"
"Icy-MetaData:1\r\n",
myurl,
ui.host,
ui.port,
useragent[0] ? useragent : "Streamripper/1.x");
#endif

/* This is the header suggested Florian Stoehr */
snprintf(buffer, MAX_HEADER_LEN + MAX_HOST_LEN + SR_MAX_PATH,
"GET %s HTTP/1.1\r\n"
"Accept: */*\r\n"
"Cache-Control: no-cache\r\n"
"User-Agent: %s\r\n"
"Icy-Metadata: 1\r\n"
"Connection: close\r\n"
"Host: %s:%d\r\n",
myurl,
useragent[0] ? useragent: "Streamripper/1.x",
ui.host,
ui.port);
/* This is the old header */
snprintf(buffer, MAX_HEADER_LEN + MAX_HOST_LEN + SR_MAX_PATH,
"GET %s HTTP/1.0\r\n"
"Host: %s:%d\r\n"
"User-Agent: %s\r\n"
"Icy-MetaData:1\r\n",
myurl,
ui.host,
ui.port,
useragent[0] ? useragent : "Streamripper/1.x");

#if defined (commentout)
/* This is the header suggested Florian Stoehr */
snprintf(buffer, MAX_HEADER_LEN + MAX_HOST_LEN + SR_MAX_PATH,
"GET %s HTTP/1.1\r\n"
"Accept: */*\r\n"
"Cache-Control: no-cache\r\n"
"User-Agent: %s\r\n"
"Icy-Metadata: 1\r\n"
"Connection: close\r\n"
"Host: %s:%d\r\n",
myurl,
useragent[0] ? useragent: "Streamripper/1.x",
ui.host,
ui.port);
#endif

Copyright © 1995-2024 Mike Lempriere (running on host bayanus)