generated from duckdb/extension-template
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support prepared statements and parameters
- Loading branch information
1 parent
bd381c1
commit f42f913
Showing
3 changed files
with
230 additions
and
69 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# name: test/sql/httpserver.test | ||
# description: test httpserver extension | ||
# group: [httpserver] | ||
|
||
# Before we load the extension, this will fail | ||
statement error | ||
SELECT httpserve_start('127.0.0.1', 4000, ''); | ||
---- | ||
Catalog Error: Scalar Function with name httpserve_start does not exist! | ||
|
||
# Require statement will ensure this test is run with this extension loaded | ||
require httpserver | ||
|
||
statement ok | ||
INSTALL http_client FROM community; | ||
|
||
statement ok | ||
LOAD http_client; | ||
|
||
statement ok | ||
INSTALL json; | ||
|
||
statement ok | ||
LOAD json; | ||
|
||
# The HTTP server is not available yet | ||
query TTT | ||
WITH response AS (SELECT http_post('http://127.0.0.1:4000/abc', MAP{}, MAP{}) response) | ||
SELECT | ||
response->>'status', | ||
response->>'reason', | ||
regexp_replace(response->>'body', '[\r\n]+', '\\n') | ||
FROM response; | ||
---- | ||
-1 HTTP POST request failed. Connection error. (empty) | ||
|
||
# Start the HTTP server | ||
query I | ||
SELECT httpserve_start('127.0.0.1', 4000, ''); | ||
---- | ||
HTTP server started on 127.0.0.1:4000 | ||
|
||
# Simple request | ||
query TTT | ||
WITH response AS (SELECT http_post('http://127.0.0.1:4000/?q=SELECT ''World'' AS Hello', MAP{}, MAP{}) response) | ||
SELECT | ||
response->>'status', | ||
response->>'reason', | ||
regexp_replace(response->>'body', '[\r\n]+', '\\n') | ||
FROM response; | ||
---- | ||
200 OK {"Hello":"World"}\n | ||
|
||
# Stop the HTTP server | ||
query I | ||
SELECT httpserve_stop(); | ||
---- | ||
HTTP server stopped | ||
|
||
# The HTTP server is not available anymore | ||
query TTT | ||
WITH response AS (SELECT http_post('http://127.0.0.1:4000/?q=SELECT ''World'' AS Hello', MAP{}, MAP{}) response) | ||
SELECT | ||
response->>'status', | ||
response->>'reason', | ||
regexp_replace(response->>'body', '[\r\n]+', '\\n') | ||
FROM response; | ||
---- | ||
-1 HTTP POST request failed. Connection error. (empty) |
This file was deleted.
Oops, something went wrong.