Problem with pkg behind a chunking proxy

sg-ball at laposte.net sg-ball at laposte.net
Tue Mar 31 22:12:03 UTC 2015


Some times ago I tried to install a FreeBSD 10.1 Release at work, where internal network is isolated from internet through a corporate proxy. And I could not make pkg work correctly.

I finally confirmed the problem was caused by the proxy using Transfer-Encoding: chunked instead of giving in first place a ContentLength header by using a python script acting as a proxy and forcing either chunked or not chunked response, and filed a bug report : https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=198772 (got no followup till now ...)

I could dive in pkg 1.4.12 source code (thanks to the port) and found that the real cause was that in libpkg/fetch.c function pkg_fetch_file_to_fd used
remote = fetchXGet(u, &st, sbuf_data(fetchOpts));
to get remote file meta data in st (notably the file size) but did not test that st.size was not -1 (what it is when using Transfer-Encoding: chunked), so the following loop getting data up to st.size simply did not run.

So I could make some minimal changes to this file (fetch.c) to accept st.size == -1. Currently it simply writes "Fetching file: 0%" until the file is fully downloaded and then write full line with "100% size speed time". Of course it runs unchanged if it gets the file size through a ContentLength header.

It would certainly be better to trace the size all along the download, but it would require changes to libpkg/event.c as well, and I prefered to limit the changes for now. For anyone interested, I join the patch to this mail.

My questions now are :
- is this the correct way to propose a patch ?
- would it be better to propose the patch for pkg-devel ?
- or should I use directly github a submit a pull request ?
- or the feature must first be discussed here ?
- or ...

I think this feature could be interesting since Transfer-Encoding: chunked is valid as HTTP 1.1 but I'm not used to submitting patches even if I've been using FreeBSD since release 3.x
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pkg_1_4_14_libpkg_fetch.patch
Type: text/x-patch
Size: 1797 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-pkg/attachments/20150331/c1503712/attachment.bin>


More information about the freebsd-pkg mailing list