[FFmpeg-devel] [PATCH] HTTP: Simplify the handling of chunked vs non-chunked posts

Martin Storsjö martin
Mon Jun 21 21:02:58 CEST 2010


On Mon, 21 Jun 2010, Ronald S. Bultje wrote:

> On Mon, Jun 21, 2010 at 2:55 PM, Martin Storsj? <martin at martin.st> wrote:
> > On Mon, 21 Jun 2010, Ronald S. Bultje wrote:
> >> On Mon, Jun 21, 2010 at 2:07 PM, Martin Storsj? <martin at martin.st> wrote:
> >> > Here's a version of the same concept, using only chunksize instead of the
> >> > is_chunked variable.
> >> [..]
> >> > @@ -152,7 +151,7 @@ static int http_open(URLContext *h, const char *uri, int flags)
> >> > ? ? ?}
> >> > ? ? ?h->priv_data = s;
> >> > ? ? ?s->filesize = -1;
> >> > - ? ?s->is_chunked = 1;
> >> > + ? ?s->chunksize = 0; /* Default to chunked POSTs */
> >> > ? ? ?s->off = 0;
> >> > ? ? ?s->init = 0;
> >> > ? ? ?s->hd = NULL;
> >> > @@ -330,16 +329,14 @@ static int http_connect(URLContext *h, const char *path, const char *hoststr,
> >> > ? ? ?s->line_count = 0;
> >> > ? ? ?s->off = 0;
> >> > ? ? ?s->filesize = -1;
> >> > - ? ?s->chunksize = -1;
> >> > ? ? ?if (post) {
> >> > - ? ? ? ?/* always use chunked encoding for upload data */
> >> > - ? ? ? ?s->chunksize = 0;
> >> > ? ? ? ? ?/* Pretend that it did work. We didn't read any header yet, since
> >> > ? ? ? ? ? * we've still to send the POST data, but the code calling this
> >> > ? ? ? ? ? * function will check http_code after we return. */
> >> > ? ? ? ? ?s->http_code = 200;
> >> > ? ? ? ? ?return 0;
> >> > ? ? ?}
> >> > + ? ?s->chunksize = -1;
> >> >
> >> > ? ? ?/* wait for header */
> >> > ? ? ?for(;;) {
> >>
> >> This breaks if the server decides to switch, the variable should be
> >> set in connect() as is done now, not in open().
> >
> > No, it doesn't. It still gets set in connect(), just as it is done now, I
> > just moved setting it down to below the if (post) block, so that we don't
> > touch it in the POST case.
> 
> Oh right, I see now. OK, both patches are fine then.

Great, applied. Thanks!

// Martin



More information about the ffmpeg-devel mailing list