tangled
alpha
login
or
join now
slices.network
/
quickslice
60
fork
atom
Auto-indexing service and GraphQL API for AT Protocol Records
quickslice.slices.network/
atproto
gleam
graphql
60
fork
atom
overview
issues
7
pulls
2
pipelines
add patch for mist sec-websocket-accept header
chadtmiller.com
4 months ago
81184748
a76d5013
+56
3 changed files
expand all
collapse all
unified
split
Dockerfile
apply-patches.sh
patches
mist-websocket-protocol.patch
+6
Dockerfile
···
22
22
# Add server code
23
23
COPY ./server /build/server
24
24
25
25
+
# Add patches directory
26
26
+
COPY ./patches /build/patches
27
27
+
25
28
# Build Rust NIFs for lexicon package (Linux build produces .so)
26
29
RUN cd /build/lexicon/native/lexicon_nif && cargo build --release && \
27
30
mkdir -p /build/lexicon/priv && \
···
31
34
RUN cd /build/lexicon && gleam deps download
32
35
RUN cd /build/lexicon_graphql && gleam deps download
33
36
RUN cd /build/server && gleam deps download
37
37
+
38
38
+
# Apply patches to dependencies
39
39
+
RUN cd /build && patch -p1 < patches/mist-websocket-protocol.patch
34
40
35
41
# Compile the server code
36
42
RUN cd /build/server \
+25
apply-patches.sh
···
1
1
+
#!/bin/bash
2
2
+
# Apply patches to dependencies after gleam build
3
3
+
# Run this after: gleam build
4
4
+
5
5
+
set -e
6
6
+
7
7
+
cd "$(dirname "$0")"
8
8
+
9
9
+
echo "Applying patches..."
10
10
+
11
11
+
# Check if the mist package exists
12
12
+
if [ ! -f "server/build/packages/mist/src/mist/internal/http.gleam" ]; then
13
13
+
echo "Error: mist package not found. Run 'cd server && gleam build' first."
14
14
+
exit 1
15
15
+
fi
16
16
+
17
17
+
# Apply the WebSocket protocol patch
18
18
+
if patch -p1 --dry-run --silent < patches/mist-websocket-protocol.patch 2>/dev/null; then
19
19
+
patch -p1 < patches/mist-websocket-protocol.patch
20
20
+
echo "✓ Applied mist WebSocket protocol patch"
21
21
+
else
22
22
+
echo "⚠ Patch already applied or failed to apply"
23
23
+
fi
24
24
+
25
25
+
echo "Done!"
+25
patches/mist-websocket-protocol.patch
···
1
1
+
--- a/server/build/packages/mist/src/mist/internal/http.gleam
2
2
+
+++ b/server/build/packages/mist/src/mist/internal/http.gleam
3
3
+
@@ -489,6 +489,9 @@ pub fn upgrade_socket(
4
4
+
|> result.replace_error(req),
5
5
+
)
6
6
+
7
7
+
+ // Check for WebSocket subprotocol (e.g., graphql-transport-ws)
8
8
+
+ let protocol = request.get_header(req, "sec-websocket-protocol")
9
9
+
+
10
10
+
let permessage_deflate = websocket.has_deflate(extensions)
11
11
+
12
12
+
let accept_key = parse_websocket_key(key)
13
13
+
@@ -500,6 +503,12 @@ pub fn upgrade_socket(
14
14
+
|> response.prepend_header("connection", "Upgrade")
15
15
+
|> response.prepend_header("sec-websocket-accept", accept_key)
16
16
+
17
17
+
+ // Add subprotocol header if requested
18
18
+
+ let resp = case protocol {
19
19
+
+ Ok(proto) -> response.prepend_header(resp, "sec-websocket-protocol", proto)
20
20
+
+ Error(_) -> resp
21
21
+
+ }
22
22
+
+
23
23
+
case permessage_deflate {
24
24
+
True ->
25
25
+
Ok(response.prepend_header(