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

Error reading response when accepting GZIP encoding #12

Closed
durango opened this issue Nov 16, 2024 · 7 comments
Closed

Error reading response when accepting GZIP encoding #12

durango opened this issue Nov 16, 2024 · 7 comments

Comments

@durango
Copy link

durango commented Nov 16, 2024

SELECT http_post(
      'https://api.openai.com/v1/chat/completions',
      headers => MAP {
        'Content-Type': 'application/json',
        'Accept': '*/*',
        'Authorization': 'Bearer <key>',
        'Host': 'api.openai.com',
        'Accept-Encoding': 'gzip, deflate, br'
      },
      params => MAP {}
  );
┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ http_post('https://api.openai.com/v1/chat/completions', headers := main."map"(main.list_value('Content-Type', 'Accept', 'Authorization', 'User-Agent', 'Host', 'Accept-Encoding'), main.list_value('application/json', '*/*', 'Bearer …  │
│                                                                                                                                 json                                                                                                                                 │
├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ { "status": -1, "reason": "HTTP POST request failed. Error reading response.", "body": "" }                                                                                                                                                                          │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
@lmangani
Copy link
Collaborator

Thanks for the report @durango this should be as simple as adding a definition to the extension including httplib.hpp

#define CPPHTTPLIB_OPENSSL_SUPPORT
#define CPPHTTPLIB_ZLIB_SUPPORT
#include "httplib.hpp"

@lmangani
Copy link
Collaborator

Well nothing is ever as easy as it looks!
I can't find a way to use ZLIB in WASM builds so that's excluded - for now. Will ask @carlopi when an opportunity arises.

@lmangani
Copy link
Collaborator

@durango #13 should offer the required functionality. Are you able to test this branch locally?

@durango
Copy link
Author

durango commented Nov 16, 2024

@lmangani looks good on that branch, glad it was a quick fix, thank you

@ahuarte47
Copy link
Collaborator

Bravo!!

@lmangani
Copy link
Collaborator

Submitted to Community Extensions repo: duckdb/community-extensions#195

@lmangani
Copy link
Collaborator

Implemented in latest release. I hope it works!

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

3 participants