Skip to content

Commit a62ec9c

Browse files
committed
Normalize headers
1 parent 4b9aec6 commit a62ec9c

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

src/apiutils.nim

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,19 @@ proc getCookieHeader(authToken, ct0: string): string =
4848

4949
proc genHeaders*(session: Session, url: Uri): Future[HttpHeaders] {.async.} =
5050
result = newHttpHeaders({
51+
"accept": "*/*",
52+
"accept-encoding": "gzip",
53+
"accept-language": "en-US,en;q=0.9",
5154
"connection": "keep-alive",
5255
"content-type": "application/json",
53-
"x-twitter-active-user": "yes",
54-
"x-twitter-client-language": "en",
5556
"origin": "https://x.com",
56-
"accept-encoding": "gzip",
57-
"accept-language": "en-US,en;q=0.5",
58-
"accept": "*/*",
59-
"DNT": "1",
60-
"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36"
57+
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36",
58+
"x-twitter-active-user": "yes",
59+
"x-twitter-client-language": "en"
6160
})
6261

6362
case session.kind
6463
of SessionKind.oauth:
65-
result["authority"] = "api.x.com"
6664
result["authorization"] = getOauthHeader($url, session.oauthToken, session.oauthSecret)
6765
of SessionKind.cookie:
6866
result["x-twitter-auth-type"] = "OAuth2Session"

src/routes/media.nim

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ proc proxyMedia*(req: jester.Request; url: string): Future[HttpCode] {.async.} =
5252
""
5353

5454
let headers = newHttpHeaders({
55-
"Content-Type": res.headers["content-type", 0],
56-
"Content-Length": contentLength,
57-
"Cache-Control": maxAge,
58-
"ETag": hashed
55+
"content-type": res.headers["content-type", 0],
56+
"content-length": contentLength,
57+
"cache-control": maxAge,
58+
"etag": hashed
5959
})
6060

6161
respond(request, headers)

0 commit comments

Comments
 (0)