Repository navigation
feat(provider): let a provider decide its own proxy - #149
Merged
Merged
Conversation
A plain-HTTP endpoint was unreachable on any machine that exports
http_proxy. evo honours the environment's proxy, and dexador — handed
:proxy — connects to it but writes an origin-form request line
("POST /v1/messages"), where a proxy requires the absolute form. xray
answers that with 400 and no body, so every request to such a provider
came back "HTTP 400: " with no tokens spent, while the same request
through curl succeeded; an HTTPS endpoint was unaffected, since HTTPS
tunnels with CONNECT.
:proxy on register-provider now decides in place of the environment:
- a proxy URL string forces that one;
- nil reaches this provider directly, whatever http_proxy/https_proxy
say — the plain-HTTP endpoint behind a machine-wide proxy;
- absent keeps the environment's answer, as before.
with-proxy takes the override as an optional third element and makes it
the proxy dexador uses, so an override is not undone by the proxy baked
into dexador at build time; perform-request carries it (the defgeneric
may not give a &key default, so the method does); call-provider sends
the provider's registered value. provider-config publishes :proxy only
when it was registered, an absent key and a nil one meaning different
things.
Co-authored-by: EvoAgent <evo@ruiqilei.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A plain-HTTP provider could not be reached on any machine that exports
http_proxy, and the failure said nothing about why: every request came backHTTP 400:with no body and no tokens spent (input 0).Why
evo deliberately resolves a proxy per request (
env-proxy, honouring thelowercase
http_proxythat dexador's own*default-proxy*misses) and handsit to dexador as
:proxy. dexador then connects to the proxy but writes anorigin-form request line:
where an HTTP proxy requires the absolute form
(
POST http://192.168.1.5:3425/v1/messages HTTP/1.1). xray answers that withHTTP/1.1 400 Bad RequestandContent-Length: 0— the empty body the agentreported. An HTTPS provider is unaffected, since HTTPS tunnels with CONNECT.
What
:proxyonregister-providernow decides in place of the environment:nilreaches this provider directly, whateverhttp_proxy/https_proxysay — the case of a plain-HTTP endpoint behind a machine-wide proxy;
with-proxytakes the override as an optional third element and makes it theproxy dexador uses, so it is not undone by a proxy baked into dexador at build
time.
perform-requestcarries it (a defgeneric lambda list may not give a&keydefault, so the method does), andcall-providerpasses the provider'sregistered value.
provider-configpublishes:proxyonly when it wasregistered: an absent key and a
nilone mean different things.Verification
make testunit suite: 2087 passed, 0 failed, including new checks thatan override beats the environment, and that absent is not
nilin theresolved config.
:proxy nil,one not, with
http_proxyset:Reply with exactly: proxy override works: