Skip to content

Commit 8d4ee0c

Browse files
authored
Merge branch 'devel' into dependabot/github_actions/actions/setup-python-6
2 parents fa132df + 406b076 commit 8d4ee0c

File tree

10 files changed

+50
-13
lines changed

10 files changed

+50
-13
lines changed

.github/workflows/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ jobs:
2020

2121
- name: Cache choosenim
2222
id: cache-choosenim
23-
uses: actions/cache@v4
23+
uses: actions/cache@v5
2424
with:
2525
path: ~/.choosenim
2626
key: ${{ runner.os }}-choosenim-${{ matrix.nim-version}}
2727

2828
- name: Cache nimble
2929
id: cache-nimble
30-
uses: actions/cache@v4
30+
uses: actions/cache@v5
3131
with:
3232
path: ~/.nimble
3333
key: ${{ runner.os }}-nimble-${{ matrix.nim-version}}-${{ hashFiles('prologue.nimble') }}

.github/workflows/docs.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
run: echo "::set-output name=dir::$(pip cache dir)"
2929

3030
- name: Cache dependencies
31-
uses: actions/cache@v4
31+
uses: actions/cache@v5
3232
with:
3333
path: ${{ steps.pip-cache.outputs.dir }}
3434
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
@@ -55,14 +55,14 @@ jobs:
5555

5656
- name: Cache choosenim
5757
id: cache-choosenim
58-
uses: actions/cache@v4
58+
uses: actions/cache@v5
5959
with:
6060
path: ~/.choosenim
6161
key: ${{ runner.os }}-choosenim-stable
6262

6363
- name: Cache nimble
6464
id: cache-nimble
65-
uses: actions/cache@v4
65+
uses: actions/cache@v5
6666
with:
6767
path: ~/.nimble
6868
key: ${{ runner.os }}-nimble-${{ hashFiles('prologue.nimble') }}

prologue.nimble

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Package
22

3-
version = "0.6.6"
3+
version = "0.6.8"
44
author = "ringabout"
55
description = "Prologue is an elegant and high performance web framework"
66
license = "Apache-2.0"
@@ -10,7 +10,7 @@ srcDir = "src"
1010
# Dependencies
1111
requires "nim >= 2.0.0"
1212
requires "regex >= 0.20.0"
13-
requires "nimcrypto >= 0.5.4"
13+
requires "nimcrypto >= 0.6.0"
1414
requires "cookiejar >= 0.2.0"
1515
requires "httpx >= 0.3.7"
1616
requires "logue >= 0.2.0"

src/prologue/core/constants.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
const
2-
PrologueVersion* = "0.6.6" ## The current version of Prologue.
2+
PrologueVersion* = "0.6.8" ## The current version of Prologue.
33
ProloguePrefix* = "PROLOGUE" ## The helper prefix for environment variables.
44
useAsyncHTTPServer* = defined(windows) or defined(usestd) ## Uses `asynchttpserver`.

src/prologue/core/form.nim

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func parseFormPart*(body, contentType: string): FormPart =
5858
tail = data[pos ..< ^2] # 2 because of protocol newline after content disposition body
5959

6060
if not head.startsWith("Content-Disposition"):
61-
break
61+
continue
6262

6363
for line in head.splitLines:
6464
let header = line.parseHeader
@@ -96,7 +96,10 @@ func parseFormPart*(body, contentType: string): FormPart =
9696

9797
func parseFormParams*(request: var Request, contentType: string) =
9898
## Parses get or post or query parameters.
99-
let mediaType = parseContentType(contentType)
99+
let mediaType = try:
100+
parseContentType(contentType)
101+
except CatchableError:
102+
MediaType(parameters: initTable[string, string]())
100103

101104
if mediaType.mainType == "application" and mediaType.subType == "x-www-form-urlencoded":
102105
request.formParams = initFormPart()

src/prologue/signing/signing.nim

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ export signingbase
4545

4646

4747
type
48-
BaseDigestType* = sha1 | sha2 | keccak | ripemd | blake2
48+
BaseDigestType* = sha1 | sha224 | sha256 | sha384 | sha512 | sha512_224 | sha512_256 | keccak | ripemd | blake2
4949

5050
BaseDigestMethodType* = enum
5151
Sha1Type,
52-
Sha224Type, Sha384Type, Sha512Type, Sha512_224Type, Sha512_256Type
52+
Sha224Type, Sha256Type, Sha384Type, Sha512Type, Sha512_224Type, Sha512_256Type
5353
Keccak224Type, Keccak256Type, Keccak384Type, Keccak512Type, Sha3_224Type,
5454
Sha3_256Type, Sha3_384Type, Sha3_512Type
5555
Ripemd128Type, Ripemd160Type, Ripemd256Type, Ripemd320Type
@@ -158,6 +158,8 @@ proc getSignatureEncode*(s: Signer | TimedSigner, value: openArray[
158158
result = getKeyDerivationEncode(s, sha1, value)
159159
of Sha224Type:
160160
result = getKeyDerivationEncode(s, sha224, value)
161+
of Sha256Type:
162+
result = getKeyDerivationEncode(s, sha256, value)
161163
of Sha384Type:
162164
result = getKeyDerivationEncode(s, sha384, value)
163165
of Sha512Type:
@@ -205,6 +207,8 @@ proc getSignatureDecode*(s: Signer | TimedSigner): string =
205207
result = getKeyDerivationDecode(s, sha1)
206208
of Sha224Type:
207209
result = getKeyDerivationDecode(s, sha224)
210+
of Sha256Type:
211+
result = getKeyDerivationDecode(s, sha256)
208212
of Sha384Type:
209213
result = getKeyDerivationDecode(s, sha384)
210214
of Sha512Type:

tests/server/tserver_application.nim

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,15 @@ block:
127127
doAssert response.code == Http200, $response.code
128128
doAssert (waitFor response.body) == "<h1>Home</h1>"
129129

130+
# "can get /query?query=foo"
131+
block:
132+
let
133+
route = "/query?query=foo"
134+
response = waitFor client.get(fmt"http://{address}:{port}{route}")
135+
136+
doAssert response.code == Http200, $response.code
137+
doAssert (waitFor response.body) == "foo"
138+
130139
# "can get /loginget using get method"
131140
block:
132141
let

tests/start_server.nim

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ proc hello*(ctx: Context) {.async.} =
1515
proc home*(ctx: Context) {.async.} =
1616
resp "<h1>Home</h1>"
1717

18+
proc query*(ctx: Context) {.async.} =
19+
let query = ctx.getQueryParamsOption("query").get("")
20+
resp query
21+
1822
proc helloName*(ctx: Context) {.async.} =
1923
resp "<h1>Hello, " & ctx.getPathParams("name", "Prologue!") & "</h1>"
2024

@@ -65,6 +69,7 @@ var app = newApp(settings = settings)
6569
with app:
6670
addRoute("/", home, HttpGet)
6771
addRoute("/home", home, HttpGet, middlewares = @[debugRequestMiddleware()])
72+
addRoute("/query", query, HttpGet)
6873
addRoute("/hello", hello, HttpGet)
6974
addRoute("/redirect", redirectHome, HttpGet)
7075
addRoute("/loginget", loginGet, HttpGet)

tests/unit/tunit_core/tunit_form

378 KB
Binary file not shown.

tests/unit/tunit_core/tunit_form.nim

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import ../../../src/prologue/core/form
2-
import tables, strutils
2+
import tables, strutils, strtabs
33

44
block:
55
const testmime =
@@ -40,3 +40,19 @@ block:
4040
let formPart = parseFormPart(testmime, contenttype)
4141
doAssert formPart.data["upload"].body.len == testfile.len
4242
doAssert formPart.data["upload"].body == testfile
43+
44+
block:
45+
# Test for file input field (issue: multipart/form-data not working)
46+
# This tests that file inputs with filename parameter work correctly
47+
const testmime =
48+
"------WebKitFormBoundary7MA4YWxkTrZu0gW\13\10" &
49+
"Content-Disposition: form-data; name=\"myfile\"; filename=\"test.txt\"\13\10" &
50+
"Content-Type: text/plain\13\10" &
51+
"\13\10" &
52+
"Hello World\13\10" &
53+
"------WebKitFormBoundary7MA4YWxkTrZu0gW--\13\10"
54+
const contenttype = "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW"
55+
let formPart = parseFormPart(testmime, contenttype)
56+
doAssert formPart.data.contains("myfile"), "myfile field should be present"
57+
doAssert formPart.data["myfile"].body == "Hello World"
58+
doAssert formPart.data["myfile"].params.getOrDefault("filename", "") == "test.txt"

0 commit comments

Comments
 (0)