| 3125 | */ |
| 3126 | |
| 3127 | int /* O - 1 if data is available, 0 otherwise */ |
| 3128 | httpWait(http_t *http, /* I - HTTP connection */ |
| 3129 | int msec) /* I - Milliseconds to wait */ |
| 3130 | { |
| 3131 | /* |
| 3132 | * First see if there is data in the buffer... |
| 3133 | */ |
| 3134 | |
| 3135 | DEBUG_printf(("2httpWait(http=%p, msec=%d)", (void *)http, msec)); |
| 3136 | |
| 3137 | if (http == NULL) |
| 3138 | return (0); |
| 3139 | |
| 3140 | if (http->used) |
| 3141 | { |
| 3142 | DEBUG_puts("3httpWait: Returning 1 since there is buffered data ready."); |
| 3143 | return (1); |
| 3144 | } |
| 3145 | |
| 3146 | #ifdef HAVE_LIBZ |
| 3147 | if (http->coding >= _HTTP_CODING_GUNZIP && ((z_stream *)http->stream)->avail_in > 0) |
| 3148 | { |
| 3149 | DEBUG_puts("3httpWait: Returning 1 since there is buffered data ready."); |
| 3150 | return (1); |
| 3151 | } |
| 3152 | #endif /* HAVE_LIBZ */ |
| 3153 | |
| 3154 | /* |
| 3155 | * Flush pending data, if any... |
| 3156 | */ |
| 3157 | |
| 3158 | if (http->wused) |
| 3159 | { |
| 3160 | DEBUG_puts("3httpWait: Flushing write buffer."); |
| 3161 | |
| 3162 | if (httpFlushWrite(http) < 0) |
| 3163 | return (0); |
| 3164 | } |
| 3165 | |
| 3166 | /* |
| 3167 | * If not, check the SSL/TLS buffers and do a select() on the connection... |
| 3168 | */ |
| 3169 | |
| 3170 | return (_httpWait(http, msec, 1)); |
| 3171 | } |
| 3172 | |
| 3173 | |
| 3174 | /* |
no test coverage detected