Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not correctly handling http status #62

Closed
hsitter opened this issue May 15, 2018 · 0 comments
Closed

not correctly handling http status #62

hsitter opened this issue May 15, 2018 · 0 comments

Comments

@hsitter
Copy link
Contributor

hsitter commented May 15, 2018

Downloading from debian repos without Packages.xz file fails silently because the status line isn't checked (i.e. the current code ignores 404 or any other fatal code entirely)

debpkgindex.d calls downloadIfNecessary for remote roots. downloadIfNecessary iters xz,gz,bz2 to find a suitable Package.* file, it calls utils.d's downloadFile which in turn simply wraps download which is where the trouble is.

download calls HTTP.perform from std.net.curl, perform however seems to not care about the status code. From the documentation, and a casual look at curl.d, I'd say that when using perform one needs to set callback handlers for everything manually. e.g. https://github.com/dlang/phobos/blob/master/std/net/curl.d#L1075 is where .get and friends get their exception thrown, perform has no such convenience magic, and the docs for .get explicitly state that a statusexception may be raised.

Some printfdebugging seems to support that theory. Setting a status line callback in download

            downloader.onReceiveStatusLine = (HTTP.StatusLine status) { logDebug ("status %s", status); };

it definitely gets code 404 but ignores it.

2018-05-15 08:29:44 - DEBUG: Downloading https://origin.archive.neon.kde.org/dev/unstable/dists/xenial/main/binary-amd64/Packages.xz
2018-05-15 08:29:44 - DEBUG: status 404 Not Found (1.1)
2018-05-15 08:29:44 - DEBUG: Downloaded https://origin.archive.neon.kde.org/dev/unstable/dists/xenial/main/binary-amd64/Packages.xz

To that end I think all that's needed to fix this is to enforce the status code, as seen in curl.d's _basicHTTP.

Config I am using:

{
"ArchiveRoot": "https://origin.archive.neon.kde.org/dev/unstable/",
"MediaBaseUrl": "https://metadata.neon.kde.org/appstream/dev/unstable/media",
"HtmlBaseUrl": "https://metadata.neon.kde.org/appstream/dev/unstable/html",
"Backend": "debian",
"Features":
  {
    "validateMetainfo": true
  },
"Suites":
  {
    "xenial":
      {
        "sections": ["main"],
        "architectures": ["amd64"],
        "useIconTheme": "breeze",
        "dataPriority": 1
      }
  }
}
@ximion ximion closed this as completed in b0d5683 Nov 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant