/*
- * $Id: http.cc,v 1.79 1996/09/20 06:28:49 wessels Exp $
+ * $Id: http.cc,v 1.80 1996/10/08 14:48:34 wessels Exp $
*
* DEBUG: section 11 Hypertext Transfer Protocol (HTTP)
* AUTHOR: Harvest Derived
char *buf = NULL;
char *t = NULL;
char *post_buf = NULL;
+ int post_buf_sz = 0;
static char *crlf = "\r\n";
int len = 0;
int buflen;
debug(11, 5, "httpSendRequest: FD %d: httpState %p.\n", fd, httpState);
buflen = strlen(Method) + strlen(req->urlpath);
if (httpState->req_hdr)
- buflen += strlen(httpState->req_hdr);
+ buflen += httpState->req_hdr_sz + 1;
buflen += 512; /* lots of extra */
if ((req->method == METHOD_POST || req->method == METHOD_PUT) && httpState->req_hdr) {
if ((t = mime_headers_end(httpState->req_hdr))) {
- post_buf = xstrdup(t);
+ post_buf_sz = httpState->req_hdr_sz - (t - httpState->req_hdr);
+ post_buf = xmalloc(post_buf_sz + 1);
+ xmemcpy(post_buf, t, post_buf_sz);
+ *(post_buf + post_buf_sz) = '\0';
*t = '\0';
}
}
strcat(buf, crlf);
len += 2;
if (post_buf) {
- strcat(buf, post_buf);
- len += strlen(post_buf);
+ xmemcpy(buf + len, post_buf, post_buf_sz);
+ len += post_buf_sz;
xfree(post_buf);
}
debug(11, 6, "httpSendRequest: FD %d:\n%s\n", fd, buf);
httpState = xcalloc(1, sizeof(HttpStateData));
storeLockObject(httpState->entry = entry, NULL, NULL);
httpState->req_hdr = entry->mem_obj->mime_hdr;
+ httpState->req_hdr_sz = entry->mem_obj->mime_hdr_sz;
request = get_free_request_t();
httpState->request = requestLink(request);
httpState->neighbor = e;
}
int
-httpStart(int unusedfd, char *url, request_t * request, char *req_hdr, StoreEntry * entry)
+httpStart(int unusedfd,
+ char *url,
+ request_t * request,
+ char *req_hdr,
+ int req_hdr_sz,
+ StoreEntry * entry)
{
/* Create state structure. */
int sock;
httpState = xcalloc(1, sizeof(HttpStateData));
storeLockObject(httpState->entry = entry, NULL, NULL);
httpState->req_hdr = req_hdr;
+ httpState->req_hdr_sz = req_hdr_sz;
httpState->request = requestLink(request);
comm_add_close_handler(sock,
(PF) httpStateFree,
/*
- * $Id: store.cc,v 1.124 1996/10/07 14:40:09 wessels Exp $
+ * $Id: store.cc,v 1.125 1996/10/08 14:48:37 wessels Exp $
*
* DEBUG: section 20 Storeage Manager
* AUTHOR: Harvest Derived
}
StoreEntry *
-storeCreateEntry(char *url, char *req_hdr, int flags, method_t method)
+storeCreateEntry(char *url,
+ char *req_hdr,
+ int req_hdr_sz,
+ int flags,
+ method_t method)
{
StoreEntry *e = NULL;
MemObject *mem = NULL;
e->url = xstrdup(url);
meta_data.url_strings += strlen(url);
e->method = method;
- if (req_hdr)
- mem->mime_hdr = xstrdup(req_hdr);
+ if (req_hdr) {
+ mem->mime_hdr_sz = req_hdr_sz;
+ mem->mime_hdr = xmalloc(req_hdr_sz + 1);
+ xmemcpy(mem->mime_hdr, req_hdr, req_hdr_sz);
+ *(mem->mime_hdr + req_hdr_sz) = '\0';
+ }
if (BIT_TEST(flags, REQ_CACHABLE)) {
BIT_SET(e->flag, ENTRY_CACHABLE);
BIT_RESET(e->flag, RELEASE_REQUEST);