跳转到主要内容

omni_httpc

Omnigres HTTP客户端

omnigres · Omnigres HTTP客户端

概览

ID扩展软件包版本类别许可证编程语言
2950omni_httpcomnigres0.1.11FEATApache-2.0C
属性可执行文件动态库需要预加载需要建扩展可迁移可信
--s-d--否是否是否否

软件包

类型仓库版本兼容的 PostgreSQL 大版本包名模式依赖
EXTPIGSTY0.1.1119 18 17 16 15omnigresomni_http, omni_types
RPMPIGSTY2026021219 18 17 16 15omnigres_$vpostgresql$v-contrib, postgresql$v-plpython3, python3-pip
DEBPIGSTY2026021219 18 17 16 15postgresql-$v-omnigrespostgresql-plpython3-$v, python3-pip
Linux / PGPG19PG18PG17PG16PG15
el8.x86_64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
el8.aarch64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
el9.x86_64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
el9.aarch64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
el10.x86_64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
el10.aarch64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
d12.x86_64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
d12.aarch64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
d13.x86_64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
d13.aarch64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
u22.x86_64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
u22.aarch64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
u24.x86_64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
u24.aarch64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
u26.x86_64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
u26.aarch64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212

源码

pig build pkg omnigres;		# build rpm/deb

安装

启用 PGDG 和 PIGSTY 仓库并更新缓存。

pig repo add pgsql -u   # add both repo and update cache

使用 pig 安装扩展。

pig install omnigres;		# install by package name
pig install omni_httpc;		# install by extension name

pig install omni_httpc -v 18;   # install for PG 18
pig install omni_httpc -v 17;   # install for PG 17
pig install omni_httpc -v 16;   # install for PG 16
pig install omni_httpc -v 15;   # install for PG 15

在数据库中创建扩展。

CREATE EXTENSION omni_httpc CASCADE; -- requires omni_http, omni_types

用法

omni_httpc: HTTP 客户端

omni_httpc 扩展提供 HTTP/1、HTTP/2 和 HTTP/3(实验性)客户端功能。

准备和执行请求

SELECT version >> 8 AS http_version, status, headers, convert_from(body, 'utf-8')
FROM omni_httpc.http_execute(
    omni_httpc.http_request('https://example.com'),
    omni_httpc.http_request('https://example.org')
);

http_request(url, method, headers, body) – 准备请求。方法默认为 GET。

http_execute(VARIADIC requests) – 执行一个或多个请求。返回 version、status、headers、body 和 error 列。

执行选项

SELECT * FROM omni_httpc.http_execute_with_options(
    omni_httpc.http_execute_options(http2_ratio => 100),
    omni_httpc.http_request('https://example.com')
);
选项类型默认值描述
http2_ratiosmallint00-100,HTTP/2 使用百分比
http3_ratiosmallint00-100,HTTP/3 使用百分比
force_cleartext_http2boolfalse使用 h2c
first_byte_timeoutint5000毫秒
timeoutint5000毫秒
follow_redirectsbooltrue跟随 HTTP 重定向
cacertstext[]nullPEM 编码的 CA 证书
clientcertclient_certificatenullPEM 编码的客户端证书

http2_ratio 和 http3_ratio 之和不得超过 100。

连接池

SELECT * FROM omni_httpc.http_connections;
-- 返回: http_protocol, url

表格阅读器