/*
- * Copyright (C) 1996-2016 The Squid Software Foundation and contributors
+ * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
*
* Squid software is distributed under GPLv2+ license and includes
* contributions from numerous individuals and organizations.
#include "Store.h"
#include "StoreClient.h"
+#include <array>
+
#if HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
return;
if ((fp = fopen(filename, "r")) == NULL) {
- debugs(25, DBG_IMPORTANT, "mimeInit: " << filename << ": " << xstrerror());
+ int xerrno = errno;
+ debugs(25, DBG_IMPORTANT, "mimeInit: " << filename << ": " << xstrerr(xerrno));
return;
}
EBIT_SET(e->flags, ENTRY_SPECIAL);
e->setPublicKey();
e->buffer();
- HttpRequest *r = HttpRequest::CreateFromUrl(url_);
- if (NULL == r)
+ const MasterXaction::Pointer mx = new MasterXaction(XactionInitiator::initIcon);
+ HttpRequestPointer r(HttpRequest::FromUrl(url_, mx));
+ if (!r)
fatalf("mimeLoadIcon: cannot parse internal URL: %s", url_);
e->mem_obj->request = r;
- HTTPMSGLOCK(e->mem_obj->request);
- HttpReply *reply = new HttpReply;
+ HttpReplyPointer reply(new HttpReply);
if (status == Http::scNoContent)
reply->setHeaders(status, NULL, NULL, 0, -1, -1);
reply->cache_control = new HttpHdrCc();
reply->cache_control->maxAge(86400);
reply->header.putCc(reply->cache_control);
- e->replaceHttpReply(reply);
+ e->replaceHttpReply(reply.getRaw());
if (status == Http::scOkay) {
/* read the file into the buffer and append it to store */
int n;
- char *buf = (char *)memAllocate(MEM_4K_BUF);
- while ((n = FD_READ_METHOD(fd, buf, sizeof(*buf))) > 0)
- e->append(buf, n);
+ std::array<char, 4096> buf;
+ while ((n = FD_READ_METHOD(fd, buf.data(), buf.size())) > 0)
+ e->append(buf.data(), n);
file_close(fd);
- memFree(buf, MEM_4K_BUF);
}
e->flush();