| 2024 | } |
| 2025 | |
| 2026 | static int http_shutdown(URLContext *h, int flags) |
| 2027 | { |
| 2028 | int ret = 0; |
| 2029 | char footer[] = "0\r\n\r\n"; |
| 2030 | HTTPContext *s = h->priv_data; |
| 2031 | |
| 2032 | /* signal end of chunked encoding if used */ |
| 2033 | if (((flags & AVIO_FLAG_WRITE) && s->chunked_post) || |
| 2034 | ((flags & AVIO_FLAG_READ) && s->chunked_post && s->listen)) { |
| 2035 | ret = ffurl_write(s->hd, footer, sizeof(footer) - 1); |
| 2036 | ret = ret > 0 ? 0 : ret; |
| 2037 | /* flush the receive buffer when it is write only mode */ |
| 2038 | if (!(flags & AVIO_FLAG_READ)) { |
| 2039 | char buf[1024]; |
| 2040 | int read_ret; |
| 2041 | s->hd->flags |= AVIO_FLAG_NONBLOCK; |
| 2042 | read_ret = ffurl_read(s->hd, buf, sizeof(buf)); |
| 2043 | s->hd->flags &= ~AVIO_FLAG_NONBLOCK; |
| 2044 | if (read_ret < 0 && read_ret != AVERROR(EAGAIN)) { |
| 2045 | av_log(h, AV_LOG_ERROR, "URL read error: %s\n", av_err2str(read_ret)); |
| 2046 | ret = read_ret; |
| 2047 | } |
| 2048 | } |
| 2049 | s->end_chunked_post = 1; |
| 2050 | } |
| 2051 | |
| 2052 | return ret; |
| 2053 | } |
| 2054 | |
| 2055 | static int http_close(URLContext *h) |
| 2056 | { |
no test coverage detected