Reply To: mt-daapd breaks ourtunes (with fix)

#6498
czeekh
Guest

Shish, I was glad to see someone else was having this problem. Here, ourTunes still hangs when I tries to connect to my server (1376 nightly). It’s not a HUGE deal (ie, I’m not going to be crushed if this can’t work), but it would be nice if ourTunes could still function with mt-daapd running.

I’m not too familiar with code editing, so feel free to point anything obvious or elementary in what I’m posting. I believe these are the relevant parts of the webserver.c file:


/*
* ws_encoding_hack
*/
int ws_encoding_hack(WS_CONNINFO *pwsc) {
char *user_agent;
int space_as_plus=1;

user_agent=ws_getrequestheader(pwsc, "user-agent");
if(user_agent) {
if(strncasecmp(user_agent,"Java",4) == 0)
space_as_plus=0;
if(strncasecmp(user_agent,"iTunes",6) == 0)
space_as_plus=0;
}
return space_as_plus;
}

AND


int ws_returnerror(WS_CONNINFO *pwsc,int error, char *description) {
char *useragent;

DPRINTF(E_WARN,L_WS,"Thread %d: Entering ws_returnerror (%d: %s)n",
pwsc->threadno,error,description);
ws_writefd(pwsc,"HTTP/1.1 %d %srn",error,description);

/* we'll force a close here unless the user agent is
iTunes, which seems to get pissy about it */
useragent = ws_getarg(&pwsc->request_headers,"User-Agent");
if((useragent) && (strncmp(useragent,"iTunes",6) == 0) && (error == 401)) {
ws_addarg(&pwsc->response_headers,"Connection","keep-alive");
ws_addarg(&pwsc->response_headers,"Content-Length","2");
ws_emitheaders(pwsc);
ws_writefd(pwsc,"rn");
return 0;
}
if((useragent) && (strncmp(useragent,"Java",4) == 0) && (error == 993)) {
ws_addarg(&pwsc->response_headers,"Connection","keep-alive");
ws_addarg(&pwsc->response_headers,"Content-Length","2");
ws_emitheaders(pwsc);
ws_writefd(pwsc,"rn");
return 0;
}

Below that, the seceond piece of code is unaltered. This is on an up-to-date Slackware 10.2 if that’s relevant. What I’m asking is if there is any error in what I’ve done here and if so, how to correct it. Any input is welcome. Thanks