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

Under what circumstances will request_uri() return an "error" string? #305

Open
xt1234567 opened this issue Dec 4, 2023 · 3 comments
Open

Comments

@xt1234567
Copy link

i use the function _M.request_uri(self, uri, params) in http.lua file, the error message it returns is the "error" string. I would like to ask whether this is a problem on the requesting side or a problem returned by the responding side. If in request side,
What is the possible root cause?

@pintsized
Copy link
Member

It can be either. A badly formed request may return nil, err -- for example if the URI cannot be parsed correctly -- before attempting to make a connection. But also an upstream connection error, or a send / read timeout can return nil, err.

The contents of the error string should make this obvious, but please post an example if it is not.

@xt1234567
Copy link
Author

thank you for your reply!
In my scenario, local resp, err = request_uri(url, req_params)
if not resp, i will retry it and print the err content.
First,the content of err is just a string "error", this is where I'm confused.
Second, I retried the request and it succeeded, so it don't like the uri can't be parsed.

@pintsized
Copy link
Member

That is odd, but I am quite certain the error string "error" could not be generated here. Note that in many cases we simply pass on the error message from the underlying cosocket.

You could try calling httpc.debug(true) globally. This will print noisy details about the generated request to your log, and so you can compare what this library is trying to do with something like curl, for example.

Please post a minimal yet complete working example that reproduces the issue if you need more help. I am guessing otherwise.

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

2 participants