Skip to content

Commit

Permalink
Merge pull request #15 from untitaker/fix-twitter-profile
Browse files Browse the repository at this point in the history
also attach additional_headers to fetchRaw requests
  • Loading branch information
PrivacyDevel authored Jul 1, 2023
2 parents 0f3203e + 939ee3b commit d8fb7aa
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/apiutils.nim
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ template fetchImpl(result, additional_headers, fetchBody) {.dirty.} =
if token.tok.len == 0:
raise rateLimitError()

if len(cfg.cookieHeader) != 0:
additional_headers.add("Cookie", cfg.cookieHeader)
if len(cfg.xCsrfToken) != 0:
additional_headers.add("x-csrf-token", cfg.xCsrfToken)

try:
var resp: AsyncResponse
var headers = genHeaders(token)
Expand Down Expand Up @@ -102,12 +107,6 @@ template fetchImpl(result, additional_headers, fetchBody) {.dirty.} =
raise rateLimitError()

proc fetch*(url: Uri; api: Api; additional_headers: HttpHeaders = newHttpHeaders()): Future[JsonNode] {.async.} =

if len(cfg.cookieHeader) != 0:
additional_headers.add("Cookie", cfg.cookieHeader)
if len(cfg.xCsrfToken) != 0:
additional_headers.add("x-csrf-token", cfg.xCsrfToken)

var body: string
fetchImpl(body, additional_headers):
if body.startsWith('{') or body.startsWith('['):
Expand Down

0 comments on commit d8fb7aa

Please sign in to comment.