nvim-lua / plenary.nvim

plenary: full; complete; entire; absolute; unqualified. All the lua functions I don't want to write twice.
MIT License
2.53k stars 270 forks source link

fixup: stream option handling in curl #557

Closed weirdgiraffe closed 3 months ago

weirdgiraffe commented 4 months ago

There are two major problems when supplying opts.stream for curl methods:

  1. curl methods produce junk in temp folder. Curl command dumps headers to some file in tmp folder and cleans it up only in the parse.response() method. This method is not called if opts.stream is set
  2. there is no way to access response code, because it is also written to the headers dump file in temp folder.

This PR address both of those problems by setting job.on_exit callback even if opts.stream is provided. Methods themselves still return job, but now user has an option to also set opts.callback to inspect the response and curl cleans up the junk in temp folder

Conni2461 commented 3 months ago

Thanks :)