Skip to content

Using easy_hook for per-request parameters #141

@c42f

Description

@c42f

Currently the easy_hook function gets passed an info parameter with URL, method and headers:

info = (url = url, method = method, headers = headers)
easy_hook(downloader, easy, info)

But I can't see how to use this to set options on a per-request basis as HTTP.jl currently allows for things like the connection timeout (https://curl.se/libcurl/c/CURLOPT_CONNECTTIMEOUT.html). Ideally we'd add connection timeouts and some other obviously useful parameters (will post a separate issue about those), but to cover more unforeseen settings it would be helpful if there was some way to get per-request items into the info struct.

I'm not sure what's best for the API. A couple of possible ideas:

  • Add an easy_hook_opts::Any=nothing keyword to request, and just pass this through in the info tuple.
  • Add an easy_hook::Union{Function,Nothing}=nothing keyword to request and invoke this on the easy handle (maybe in addition to the easy hook which is contained in the Downloader).

I kind of favor the second of these ideas. Perhaps not as a public part of the API, but as an escape hatch it sure would be handy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions