You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/kb/http.md
+54-50Lines changed: 54 additions & 50 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,57 @@ keywords: browser, http, https, kdb+, q, web
5
5
---
6
6
# :fontawesome-solid-handshake: HTTP
7
7
8
+
## HTTP server
9
+
10
+
kdb+ has an in-built service capable of handling HTTP/HTTPS requests.
11
+
12
+
### Listening port
13
+
14
+
When kdb+ is [configured](../basics/listening-port.md) to listen on a port, it uses the same port as that serving kdb+ IPC and websocket connections.
15
+
16
+
### SSL/TLS
17
+
18
+
HTTPS can be handled once kdb+ has been [configured to use SSL/TLS](ssl.md).
19
+
20
+
### Authentication / Authorization
21
+
22
+
Client requests can be authenticated/authorized using [.z.ac](../ref/dotz.md#zac-http-auth).
23
+
This allows kdb+ to be customized with a variety of mechanisms for securing HTTP requests e.g. LDAP, OAuth2, OpenID Connect, etc.
24
+
25
+
### Request handling
26
+
27
+
HTTP request handling is customized by using the following callbacks:
28
+
29
+
*[.z.ph](../ref/dotz.md#zph-http-get) for HTTP GET
30
+
*[.z.pp](../ref/dotz.md##zpp-http-post) for HTTP POST
31
+
*[.z.pm](../ref/dotz.md##zpp-http-post) for HTTP OPTIONS/PATCH/PUT/DELETE
32
+
33
+
#### Default .z.ph handling
34
+
35
+
The default implementation of .z.ph displays all variables and views. For example, starting kdb+ listening on port (`q -p 8080`) and visiting `http://localhost:8080` from a web browser on the same machine, displays all created variables/views).
36
+
37
+
Providing q code as a GET param causes it to be evaluated eg. `http://localhost:8080?1+1` returns `2`.
38
+
39
+
[.h.HOME](../ref/doth.md#hhome-webserver-root) can be set to be the webserver root to serve files contained in the directory e.g.
40
+
creating an HTML file index.html in directory `/webserver/` and setting `.h.HOME="/webserver"` allows the file to be viewed via `http://localhost:8080/index.html'.
Persistent connections to supported clients can be enabled via [.h.ka](../ref/doth.md#hka-http-keepalive)
51
+
52
+
### Compression
53
+
54
+
HTTP server supports gzip compression via `Content-Encoding: gzip` for responses to `form?…`-style requests.
55
+
The response payload must be 2,000+ chars and the client must indicate support via `Accept-Encoding: gzip` in the HTTP header.
56
+
(Since V4.0 2020.03.17.)
57
+
58
+
8
59
## HTTP client
9
60
10
61
### Creating HTTP requests
@@ -81,61 +132,14 @@ q)@["\r\n\r\n" vs x;1]
81
132
82
133
To use SSL/TLS, kdb+ should first be [configured to use SSL/TLS](ssl.md). For any request requiring SSL/TLS, replace `http` with `https`.
83
134
84
-
## HTTP server
85
-
86
-
kdb+ has an in-built service capable of handling HTTP/HTTPS requests.
87
-
88
-
### Listening port
89
-
90
-
When kdb+ is [configured](../basics/listening-port.md) to listen on a port, it uses the same port as that serving kdb+ IPC and websocket connections.
91
-
92
-
### SSL/TLS
93
-
94
-
HTTPS can be handled once kdb+ has been [configured to use SSL/TLS](ssl.md).
95
-
96
-
### Authentication / Authorization
97
-
98
-
Client requests can be authenticated/authorized using [.z.ac](../ref/dotz.md#zac-http-auth).
99
-
This allows kdb+ to be customized with a variety of mechanisms for securing HTTP requests e.g. LDAP, OAuth2, OpenID Connect, etc.
100
-
101
-
### Request handling
102
-
103
-
HTTP request handling is customized by using the following callbacks:
104
-
105
-
*[.z.ph](../ref/dotz.md#zph-http-get) for HTTP GET
106
-
*[.z.pp](../ref/dotz.md##zpp-http-post) for HTTP POST
107
-
*[.z.pm](../ref/dotz.md##zpp-http-post) for HTTP OPTIONS/PATCH/PUT/DELETE
108
-
109
-
#### Default .z.ph handling
110
-
111
-
The default implementation of .z.ph displays all variables and views. For example, starting kdb+ listening on port (`q -p 8080`) and visiting `http://localhost:8080` from a web browser on the same machine, displays all created variables/views).
112
135
113
-
Providing q code as a GET param causes it to be evaluated eg. `http://localhost:8080?1+1` returns `2`.
114
-
115
-
[.h.HOME](../ref/doth.md#hhome-webserver-root) can be set to be the webserver root in order to serve files contained in the directory e.g.
116
-
creating an HTML file index.html in directory `/webserver/` and setting `.h.HOME="/webserver"` allows the file to be viewed via `http://localhost:8080/index.html'.
0 commit comments