- safestrncpy(buf, ChrPtr(WC->UrlFragment2), sizeof buf);
- unescape_input(buf);
- serv_printf("OPEN %s", buf);
- serv_getln(buf, sizeof buf);
- if (buf[0] == '2') {
- bytes = extract_long(&buf[4], 0);
- content = malloc(bytes + 2);
- if (force_download) {
- strcpy(content_type, "application/octet-stream");
- }
- else {
- extract_token(content_type, &buf[4], 3, '|', sizeof content_type);
+ Buf = NewStrBuf();
+ StrBufUnescape(WCC->UrlFragment2, 1);
+ serv_printf("OPEN %s", ChrPtr(WCC->UrlFragment2));
+ StrBuf_ServGetlnBuffered(Buf);
+ if (GetServerStatus(Buf, NULL) == 2) {
+ StrBufCutLeft(Buf, 4);
+ bytes = StrBufExtract_long(Buf, 0, '|');
+ if (!force_download) {
+ StrBufExtract_token(ContentType, Buf, 3, '|');