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

Martin Storsjö martin
Mon Jun 21 20:07:01 CEST 2010


On Mon, 21 Jun 2010, Martin Storsj? wrote:

> On Mon, 21 Jun 2010, Ronald S. Bultje wrote:
> 
> > On Mon, Jun 21, 2010 at 4:45 AM, Martin Storsj? <martin at martin.st> wrote:
> > > This simplifies some code in the http protocol, and makes the comments
> > > actually reflect what the code does.
> > [..]
> > > @@ -434,7 +435,7 @@ static int http_write(URLContext *h, const uint8_t *buf, int size)
> > >          return AVERROR(EIO);
> > >
> > >      if (s->chunksize == -1) {
> > > -        /* headers are sent without any special encoding */
> > > +        /* non-chunked data is sent without any special encoding */
> > >          return url_write(s->hd, buf, size);
> > >      }
> > >  @@ -442,16 +443,14 @@ static int http_write(URLContext *h, const uint8_t *buf, int size)
> > >       * signal EOF */
> > >      if (size > 0) {
> > >          /* upload data using chunked encoding */
> > > -        if(s->is_chunked) {
> > >              snprintf(temp, sizeof(temp), "%x\r\n", size);
> > >              if ((ret = url_write(s->hd, temp, strlen(temp))) < 0)
> > >                  return ret;
> > > -        }
> > >
> > >          if ((ret = url_write(s->hd, buf, size)) < 0)
> > >              return ret;
> > >
> > > -        if (s->is_chunked && (ret = url_write(s->hd, crlf, sizeof(crlf) - 1)) < 0)
> > > +        if ((ret = url_write(s->hd, crlf, sizeof(crlf) - 1)) < 0)
> > >              return ret;
> > >      }
> > >      return size;
> > 
> > Why do we have this is_chunked variable again? It should be chunksize
> > >=0 chunked, chunksize == -1 => unchuncked. Let's remove that
> 
> We have it for setting whether chunked mode is desired for POSTs. I'll try 
> to think it through and see if we can eliminate it completely, 
> preferrabily in the setup with AVOptions as I posted in the other thread.

Here's a version of the same concept, using only chunksize instead of the 
is_chunked variable.

// Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Get-rid-of-the-is_chunked-variable-use-the-chunksize.patch
Type: text/x-diff
Size: 3434 bytes
Desc: 
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100621/205cf9b1/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Compact-the-code-for-writing-chunked-http-post-data.patch
Type: text/x-diff
Size: 1195 bytes
Desc: 
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100621/205cf9b1/attachment-0001.patch>



More information about the ffmpeg-devel mailing list