- 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);
- }
- output_headers(0, 0, 0, 0, 0, 0);
- read_server_binary(WC->WBuf, bytes);
+ Buf = NewStrBuf();
+ StrBufExtract_token(Buf, WCC->Hdr->HR.ReqLine, 0, '/');
+ StrBufUnescape(Buf, 1);
+ serv_printf("OPEN %s", ChrPtr(Buf));
+ StrBuf_ServGetln(Buf);
+ if (GetServerStatus(Buf, NULL) == 2) {
+ StrBufCutLeft(Buf, 4);
+ bytes = StrBufExtract_long(Buf, 0, '|');
+ StrBufExtract_token(ContentType, Buf, 3, '|');
+
+ CheckGZipCompressionAllowed (SKEY(ContentType));
+ if (force_download)
+ FlushStrBuf(ContentType);
+
+ serv_read_binary_to_http(ContentType, bytes, 0, 0);