#define OFFSET(x) offsetof(HTTPContext, x)
static const AVOption options[] = {
-{"chunksize", "use chunked transfer-encoding for posts, -1 disables it, 0 enables it", OFFSET(chunksize), FF_OPT_TYPE_INT64, 0, -1, 0 }, /* Default to 0, for chunked POSTs */
+{"chunksize", "use chunked transfer-encoding for posts, -1 disables it, 0 enables it", OFFSET(chunksize), FF_OPT_TYPE_INT64, {.dbl = 0}, -1, 0 }, /* Default to 0, for chunked POSTs */
{NULL}
};
static const AVClass httpcontext_class = {
- "HTTP", av_default_item_name, options, LIBAVUTIL_VERSION_INT
+ .class_name = "HTTP",
+ .item_name = av_default_item_name,
+ .option = options,
+ .version = LIBAVUTIL_VERSION_INT,
};
static int http_connect(URLContext *h, const char *path, const char *hoststr,
int len = strlen(headers);
if (len && strcmp("\r\n", headers + len - 2))
- av_log(NULL, AV_LOG_ERROR, "No trailing CRLF found in HTTP header.\n");
+ av_log(h, AV_LOG_ERROR, "No trailing CRLF found in HTTP header.\n");
av_strlcpy(s->headers, headers, sizeof(s->headers));
}
port = 80;
ff_url_join(buf, sizeof(buf), "tcp", NULL, hostname, port, NULL);
- err = ffurl_open(&hd, buf, URL_RDWR);
+ err = ffurl_open(&hd, buf, AVIO_FLAG_READ_WRITE);
if (err < 0)
goto fail;
goto fail;
if (s->http_code == 401) {
if (cur_auth_type == HTTP_AUTH_NONE && s->auth_state.auth_type != HTTP_AUTH_NONE) {
- url_close(hd);
+ ffurl_close(hd);
goto redo;
} else
goto fail;
if ((s->http_code == 301 || s->http_code == 302 || s->http_code == 303 || s->http_code == 307)
&& location_changed == 1) {
/* url moved, get next */
- url_close(hd);
+ ffurl_close(hd);
if (redirects++ >= MAX_REDIRECTS)
return AVERROR(EIO);
location_changed = 0;
return 0;
fail:
if (hd)
- url_close(hd);
+ ffurl_close(hd);
s->hd = NULL;
return AVERROR(EIO);
}
* don't abort until all headers have been parsed. */
if (s->http_code >= 400 && s->http_code < 600 && s->http_code != 401) {
end += strspn(end, SPACE_CHARS);
- av_log(NULL, AV_LOG_WARNING, "HTTP error %d %s\n",
+ av_log(h, AV_LOG_WARNING, "HTTP error %d %s\n",
s->http_code, end);
return -1;
}
/* send http header */
- post = h->flags & URL_WRONLY;
+ post = h->flags & AVIO_FLAG_WRITE;
authstr = ff_http_auth_create_response(&s->auth_state, auth, path,
post ? "POST" : "GET");
HTTPContext *s = h->priv_data;
/* signal end of chunked encoding if used */
- if ((h->flags & URL_WRONLY) && s->chunksize != -1) {
+ if ((h->flags & AVIO_FLAG_WRITE) && s->chunksize != -1) {
ret = ffurl_write(s->hd, footer, sizeof(footer) - 1);
ret = ret > 0 ? 0 : ret;
}
if (s->hd)
- url_close(s->hd);
+ ffurl_close(s->hd);
return ret;
}
s->off = old_off;
return -1;
}
- url_close(old_hd);
+ ffurl_close(old_hd);
return off;
}
http_get_file_handle(URLContext *h)
{
HTTPContext *s = h->priv_data;
- return url_get_file_handle(s->hd);
+ return ffurl_get_file_handle(s->hd);
}
URLProtocol ff_http_protocol = {
- "http",
- http_open,
- http_read,
- http_write,
- http_seek,
- http_close,
+ .name = "http",
+ .url_open = http_open,
+ .url_read = http_read,
+ .url_write = http_write,
+ .url_seek = http_seek,
+ .url_close = http_close,
.url_get_file_handle = http_get_file_handle,
- .priv_data_size = sizeof(HTTPContext),
- .priv_data_class = &httpcontext_class,
+ .priv_data_size = sizeof(HTTPContext),
+ .priv_data_class = &httpcontext_class,
};