MemBuf httpPackedReply(http_version_t ver, http_status status, const char *ctype, squid_off_t clen, time_t lmt, time_t expires) { HttpReply *rep = httpReplyCreate(); MemBuf mb; httpReplySetHeaders(rep, ver, status, ctype, NULL, clen, lmt, expires); mb = httpReplyPack(rep); httpReplyDestroy(rep); return mb; }
/* * Function: errorSend * * Arguments: err - This object is destroyed after use in this function. * * Abstract: This function generates a error page from the info contained * by 'err' and then sends it to the client. * The callback function errorSendComplete() is called after * the page has been written to the client socket (fd). * errorSendComplete() deallocates 'err'. We need to add * 'err' to the cbdata because comm_write() requires it * for all callback data pointers. * * Note, normally errorSend() should only be called from * routines in ssl.c and pass.c, where we don't have any * StoreEntry's. In client_side.c we must allocate a StoreEntry * for errors and use errorAppendEntry() to account for * persistent/pipeline connections. */ void errorSend(int fd, ErrorState * err) { HttpReply *rep; debug(4, 3) ("errorSend: FD %d, err=%p\n", fd, err); assert(fd >= 0); /* * ugh, this is how we make sure error codes get back to * the client side for logging and error tracking. */ if (err->request) err->request->err_type = err->type; /* moved in front of errorBuildBuf @?@ */ err->flags.flag_cbdata = 1; rep = errorBuildReply(err); comm_write_mbuf(fd, httpReplyPack(rep), errorSendComplete, err); httpReplyDestroy(rep); }