| 5825 | */ |
| 5826 | |
| 5827 | static void * /* O - Exit status */ |
| 5828 | process_client(ippeve_client_t *client) /* I - Client */ |
| 5829 | { |
| 5830 | /* |
| 5831 | * Loop until we are out of requests or timeout (30 seconds)... |
| 5832 | */ |
| 5833 | |
| 5834 | #ifdef HAVE_TLS |
| 5835 | int first_time = 1; /* First time request? */ |
| 5836 | #endif /* HAVE_TLS */ |
| 5837 | |
| 5838 | while (httpWait(client->http, 30000)) |
| 5839 | { |
| 5840 | #ifdef HAVE_TLS |
| 5841 | if (first_time) |
| 5842 | { |
| 5843 | /* |
| 5844 | * See if we need to negotiate a TLS connection... |
| 5845 | */ |
| 5846 | |
| 5847 | char buf[1]; /* First byte from client */ |
| 5848 | |
| 5849 | if (recv(httpGetFd(client->http), buf, 1, MSG_PEEK) == 1 && (!buf[0] || !strchr("DGHOPT", buf[0]))) |
| 5850 | { |
| 5851 | fprintf(stderr, "%s Starting HTTPS session.\n", client->hostname); |
| 5852 | |
| 5853 | if (httpEncryption(client->http, HTTP_ENCRYPTION_ALWAYS)) |
| 5854 | { |
| 5855 | fprintf(stderr, "%s Unable to encrypt connection: %s\n", client->hostname, cupsLastErrorString()); |
| 5856 | break; |
| 5857 | } |
| 5858 | |
| 5859 | fprintf(stderr, "%s Connection now encrypted.\n", client->hostname); |
| 5860 | } |
| 5861 | |
| 5862 | first_time = 0; |
| 5863 | } |
| 5864 | #endif /* HAVE_TLS */ |
| 5865 | |
| 5866 | if (!process_http(client)) |
| 5867 | break; |
| 5868 | } |
| 5869 | |
| 5870 | /* |
| 5871 | * Close the connection to the client and return... |
| 5872 | */ |
| 5873 | |
| 5874 | delete_client(client); |
| 5875 | |
| 5876 | return (NULL); |
| 5877 | } |
| 5878 | |
| 5879 | |
| 5880 | /* |
nothing calls this directly
no test coverage detected