MCPcopy Create free account
hub / github.com/OpenPrinting/cups / http_write_chunk

Function http_write_chunk

cups/http.c:4884–4919  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4882 */
4883
4884static ssize_t /* O - Number bytes written */
4885http_write_chunk(http_t *http, /* I - HTTP connection */
4886 const char *buffer, /* I - Buffer to write */
4887 size_t length) /* I - Length of buffer */
4888{
4889 char header[16]; /* Chunk header */
4890 ssize_t bytes; /* Bytes written */
4891
4892
4893 DEBUG_printf(("7http_write_chunk(http=%p, buffer=%p, length=" CUPS_LLFMT ")", (void *)http, (void *)buffer, CUPS_LLCAST length));
4894
4895 /*
4896 * Write the chunk header, data, and trailer.
4897 */
4898
4899 snprintf(header, sizeof(header), "%x\r\n", (unsigned)length);
4900 if (http_write(http, header, strlen(header)) < 0)
4901 {
4902 DEBUG_puts("8http_write_chunk: http_write of length failed.");
4903 return (-1);
4904 }
4905
4906 if ((bytes = http_write(http, buffer, length)) < 0)
4907 {
4908 DEBUG_puts("8http_write_chunk: http_write of buffer failed.");
4909 return (-1);
4910 }
4911
4912 if (http_write(http, "\r\n", 2) < 0)
4913 {
4914 DEBUG_puts("8http_write_chunk: http_write of CR LF failed.");
4915 return (-1);
4916 }
4917
4918 return (bytes);
4919}

Callers 3

httpFlushWriteFunction · 0.85
httpWrite2Function · 0.85

Calls 1

http_writeFunction · 0.85

Tested by

no test coverage detected