[emacs-berlin] Code review for a simple HTTP async client

Michael Heerdegen michael_heerdegen at web.de
Fri Jan 5 00:10:25 UTC 2024


jman <emacs-berlin at city17.xyz> writes:

> IIUC the workflow, the logic should be:
> - a function runs `url-retrieve url 'callback`
> - same function should register (?) a filter process where the callback
> will write its output
> - the callback parses the HTTP response
> - at some point the function should see some output in the filtered
> buffer

Your case is very simple - using the callback of `url-retrieve' is
enough.  The callback is internally called by a filter of an
automatically created process.  You don't need to use process filters
explicitly.

What's wrong in your above template is that the function that calls
`url-retrieve' will finish before the output is available.  It will
_not_ be the same function that runs when the output is ready.  This
doesn't make a difference though - just put the code you want to run
when the output is available into the callback.  That's all.

Michael.


More information about the emacs-berlin mailing list