PRIVATE int HTSC_putBlock (HTStream * me, const char * b, int l) { me->cur_size += l; /* ** If we get a buffer overflow and we are going to PUT or POST the document ** then ask the user whether it is OK to proceed buffering. Otherwise we ** must give up the request. In all other cases we stop if the buffer fills ** up. */ if (!me->ignore && me->max_size > 0 && me->cur_size > me->max_size) { HTMethod method = HTRequest_method(me->request); if (HTMethod_hasEntity(method)) { HTAlertCallback *cbf = HTAlert_find(HT_A_CONFIRM); if ((cbf && (*cbf)(me->request, HT_A_CONFIRM, HT_MSG_BIG_PUT, NULL, NULL, NULL))) me->ignore = YES; else me->give_up = YES; } else { me->give_up = YES; } } else if (!me->ensure) { HTParentAnchor * anchor = HTRequest_anchor(me->request); int cl = HTAnchor_length(anchor); if (cl > 0) HTChunk_ensure(me->chunk, cl); me->ensure = YES; } if (!me->give_up) { HTChunk_putb(me->chunk, b, l); return HT_OK; } return HT_ERROR; }
/* Set the "size" of the Chunk's data ** ----------------------------------- ** The actual allocated length must be at least 1 byte longer to hold the ** mandatory null terminator. */ PUBLIC BOOL HTChunk_setSize (HTChunk * ch, int length) { if (ch && length >= 0) { if (length < ch->size) memset(ch->data+length, '\0', ch->size-length); else if (length >= ch->allocated) HTChunk_ensure(ch, length - ch->size); ch->size = length; return YES; } return NO; }