add ff_http_do_new_request2() which supports options to be applied to HTTPContext after initialisation with the new uri
Unified · Split
| @@ -320,8 +320,11 @@ int ff_http_get_shutdown_status(URLContext *h) · 319 unmodified lines | ||
| 320 | 320 | return ret; |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | +int ff_http_do_new_request(URLContext *h, const char *uri) { | |
| 324 | + return ff_http_do_new_request2(h, uri, NULL); | |
| 325 | +} | |
| 323 | 326 | |
| 324 | −int ff_http_do_new_request(URLContext *h, const char *uri) | |
| 327 | +int ff_http_do_new_request2(URLContext *h, const char *uri, AVDictionary **opts) | |
| 325 | 328 | { |
| 326 | 329 | HTTPContext *s = h->priv_data; |
| 327 | 330 | AVDictionary *options = NULL; |
| @@ -366,6 +369,9 @@ int ff_http_do_new_request(URLContext *h, const char *uri) · 38 unmodified lines | ||
| 366 | 369 | if (!s->location) |
| 367 | 370 | return AVERROR(ENOMEM); |
| 368 | 371 | |
| 372 | + if ((ret = av_opt_set_dict(s, opts)) < 0) | |
| 373 | + return ret; | |
| 374 | + | |
| 369 | 375 | av_log(s, AV_LOG_INFO, "Opening \'%s\' for %s\n", uri, h->flags & AVIO_FLAG_WRITE ? "writing" : "reading"); |
| 370 | 376 | ret = http_open_cnx(h, &options); |
| 371 | 377 | av_dict_free(&options); |
| @@ -56,6 +56,19 @@ int ff_http_get_shutdown_status(URLContext *h); · 55 unmodified lines | ||
| 56 | 56 | */ |
| 57 | 57 | int ff_http_do_new_request(URLContext *h, const char *uri); |
| 58 | 58 | |
| 59 | +/** | |
| 60 | + * Send a new HTTP request, reusing the old connection. | |
| 61 | + * | |
| 62 | + * @param h pointer to the resource | |
| 63 | + * @param uri uri used to perform the request | |
| 64 | + * @param options A dictionary filled with HTTP options. On return | |
| 65 | + * this parameter will be destroyed and replaced with a dict containing options | |
| 66 | + * that were not found. May be NULL. | |
| 67 | + * @return a negative value if an error condition occurred, 0 | |
| 68 | + * otherwise | |
| 69 | + */ | |
| 70 | +int ff_http_do_new_request2(URLContext *h, const char *uri, AVDictionary **options); | |
| 71 | + | |
| 59 | 72 | int ff_http_averror(int status_code, int default_averror); |
| 60 | 73 | |
| 61 | 74 | #endif /* AVFORMAT_HTTP_H */ |