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

Function httpGets

cups/http.c:1150–1318  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1148 */
1149
1150char * /* O - Line or @code NULL@ */
1151httpGets(char *line, /* I - Line to read into */
1152 int length, /* I - Max length of buffer */
1153 http_t *http) /* I - HTTP connection */
1154{
1155 char *lineptr, /* Pointer into line */
1156 *lineend, /* End of line */
1157 *bufptr, /* Pointer into input buffer */
1158 *bufend; /* Pointer to end of buffer */
1159 ssize_t bytes; /* Number of bytes read */
1160 int eol; /* End-of-line? */
1161
1162
1163 DEBUG_printf(("2httpGets(line=%p, length=%d, http=%p)", (void *)line, length, (void *)http));
1164
1165 if (!http || !line || length <= 1)
1166 return (NULL);
1167
1168 /*
1169 * Read a line from the buffer...
1170 */
1171
1172 http->error = 0;
1173 lineptr = line;
1174 lineend = line + length - 1;
1175 eol = 0;
1176
1177 while (lineptr < lineend)
1178 {
1179 /*
1180 * Pre-load the buffer as needed...
1181 */
1182
1183#ifdef _WIN32
1184 WSASetLastError(0);
1185#else
1186 errno = 0;
1187#endif /* _WIN32 */
1188
1189 while (http->used == 0)
1190 {
1191 /*
1192 * No newline; see if there is more data to be read...
1193 */
1194
1195 while (!_httpWait(http, http->wait_value, 1))
1196 {
1197 if (http->timeout_cb && (*http->timeout_cb)(http, http->timeout_data))
1198 continue;
1199
1200 DEBUG_puts("3httpGets: Timed out!");
1201#ifdef _WIN32
1202 http->error = WSAETIMEDOUT;
1203#else
1204 http->error = ETIMEDOUT;
1205#endif /* _WIN32 */
1206 return (NULL);
1207 }

Callers 5

httpPeekFunction · 0.85
httpRead2Function · 0.85
httpReadRequestFunction · 0.85
_httpUpdateFunction · 0.85
http_read_chunkFunction · 0.85

Calls 2

_httpWaitFunction · 0.85
http_readFunction · 0.85

Tested by

no test coverage detected