Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails basic Form example #213

Open
juancarlospaco opened this issue Oct 4, 2019 · 6 comments

Comments

@juancarlospaco
Copy link

commented Oct 4, 2019

Example

import jester

routes:
  get "/":
    resp """
    <form name="login" action="/dologin" method="post">
      <input type="text" id="username" name="username" value="somevalue">
      <input type="submit"/>
    </form>
    """

  post "/dologin":
    assert @"username" == "somevalue", @"username"

Traceback

$ nim c -r example.nim           
                                                                                                                      
Hint: /home/juan/code/temp2/example  [Exec]
INFO Jester is making jokes at http://0.0.0.0:5000
Starting 1 threads
DEBUG POST /dologin
ERROR /home/juan/code/temp2/example.nim(3) example
/home/juan/.nimble/pkgs/jester-0.4.3/jester.nim(482) serve
/home/juan/.nimble/pkgs/httpbeast-0.2.2/httpbeast.nim(423) run
/home/juan/.nimble/pkgs/httpbeast-0.2.2/httpbeast.nim(287) eventLoop
/home/juan/.nimble/pkgs/httpbeast-0.2.2/httpbeast.nim(219) processEvents
/home/juan/.nimble/pkgs/jester-0.4.3/jester.nim(485) :anonymous
/home/juan/.nimble/pkgs/jester-0.4.3/jester.nim(386) handleRequest
/home/juan/.choosenim/toolchains/nim-1.0.0/lib/pure/asyncmacro.nim(311) dispatch
/home/juan/.choosenim/toolchains/nim-1.0.0/lib/pure/asyncmacro.nim(34) dispatchNimAsyncContinue
/home/juan/.nimble/pkgs/jester-0.4.3/jester.nim(285) dispatchIter
/home/juan/.choosenim/toolchains/nim-1.0.0/lib/pure/asyncmacro.nim(311) match
/home/juan/.choosenim/toolchains/nim-1.0.0/lib/pure/asyncmacro.nim(34) matchNimAsyncContinue
/home/juan/code/temp2/example.nim(13) matchIter
/home/juan/.choosenim/toolchains/nim-1.0.0/lib/system/assertions.nim(27) failedAssertImpl
/home/juan/.choosenim/toolchains/nim-1.0.0/lib/system/assertions.nim(20) raiseAssert
/home/juan/.choosenim/toolchains/nim-1.0.0/lib/system/fatal.nim(39) sysFatal
[[reraised from:
/home/juan/code/temp2/example.nim(3) example
/home/juan/.nimble/pkgs/jester-0.4.3/jester.nim(482) serve
/home/juan/.nimble/pkgs/httpbeast-0.2.2/httpbeast.nim(423) run
/home/juan/.nimble/pkgs/httpbeast-0.2.2/httpbeast.nim(287) eventLoop
/home/juan/.nimble/pkgs/httpbeast-0.2.2/httpbeast.nim(219) processEvents
/home/juan/.nimble/pkgs/jester-0.4.3/jester.nim(485) :anonymous
/home/juan/.nimble/pkgs/jester-0.4.3/jester.nim(386) handleRequest
/home/juan/.choosenim/toolchains/nim-1.0.0/lib/pure/asyncmacro.nim(311) dispatch
/home/juan/.choosenim/toolchains/nim-1.0.0/lib/pure/asyncmacro.nim(37) dispatchNimAsyncContinue
/home/juan/.nimble/pkgs/jester-0.4.3/jester.nim(285) dispatchIter
/home/juan/.choosenim/toolchains/nim-1.0.0/lib/pure/asyncfutures.nim(383) read
]]
[[reraised from:
/home/juan/code/temp2/example.nim(3) example
/home/juan/.nimble/pkgs/jester-0.4.3/jester.nim(482) serve
/home/juan/.nimble/pkgs/httpbeast-0.2.2/httpbeast.nim(423) run
/home/juan/.nimble/pkgs/httpbeast-0.2.2/httpbeast.nim(287) eventLoop
/home/juan/.nimble/pkgs/httpbeast-0.2.2/httpbeast.nim(219) processEvents
/home/juan/.nimble/pkgs/jester-0.4.3/jester.nim(485) :anonymous
/home/juan/.nimble/pkgs/jester-0.4.3/jester.nim(386) handleRequest
/home/juan/.choosenim/toolchains/nim-1.0.0/lib/pure/asyncmacro.nim(311) handleRequestSlow
/home/juan/.choosenim/toolchains/nim-1.0.0/lib/pure/asyncmacro.nim(37) handleRequestSlowNimAsyncContinue
/home/juan/.nimble/pkgs/jester-0.4.3/jester.nim(336) handleRequestSlowIter
/home/juan/.choosenim/toolchains/nim-1.0.0/lib/pure/asyncfutures.nim(383) read
]]
/home/juan/code/temp2/example.nim(13, 12) `@"username" == "somevalue"` 
Async traceback:
  /home/juan/code/temp2/example.nim(3)                                      example
  /home/juan/.nimble/pkgs/jester-0.4.3/jester.nim(482)                      serve
  /home/juan/.nimble/pkgs/httpbeast-0.2.2/httpbeast.nim(423)                run
  /home/juan/.nimble/pkgs/httpbeast-0.2.2/httpbeast.nim(287)                eventLoop
  /home/juan/.nimble/pkgs/httpbeast-0.2.2/httpbeast.nim(219)                processEvents
  /home/juan/.nimble/pkgs/jester-0.4.3/jester.nim(485)                      :anonymous
  /home/juan/.nimble/pkgs/jester-0.4.3/jester.nim(386)                      handleRequest
  /home/juan/.choosenim/toolchains/nim-1.0.0/lib/pure/asyncmacro.nim(311)   dispatch
  /home/juan/.choosenim/toolchains/nim-1.0.0/lib/pure/asyncmacro.nim(34)    dispatchNimAsyncContinue
  /home/juan/.nimble/pkgs/jester-0.4.3/jester.nim(285)                      dispatchIter
  /home/juan/.choosenim/toolchains/nim-1.0.0/lib/pure/asyncmacro.nim(311)   match
  /home/juan/.choosenim/toolchains/nim-1.0.0/lib/pure/asyncmacro.nim(34)    matchNimAsyncContinue
  /home/juan/code/temp2/example.nim(13)                                     matchIter
  /home/juan/.choosenim/toolchains/nim-1.0.0/lib/system/assertions.nim(27)  failedAssertImpl
  /home/juan/.choosenim/toolchains/nim-1.0.0/lib/system/assertions.nim(20)  raiseAssert
  /home/juan/.choosenim/toolchains/nim-1.0.0/lib/system/fatal.nim(39)       sysFatal
  #[
    /home/juan/code/temp2/example.nim(3)                                      example
    /home/juan/.nimble/pkgs/jester-0.4.3/jester.nim(482)                      serve
    /home/juan/.nimble/pkgs/httpbeast-0.2.2/httpbeast.nim(423)                run
    /home/juan/.nimble/pkgs/httpbeast-0.2.2/httpbeast.nim(287)                eventLoop
    /home/juan/.nimble/pkgs/httpbeast-0.2.2/httpbeast.nim(219)                processEvents
    /home/juan/.nimble/pkgs/jester-0.4.3/jester.nim(485)                      :anonymous
    /home/juan/.nimble/pkgs/jester-0.4.3/jester.nim(386)                      handleRequest
    /home/juan/.choosenim/toolchains/nim-1.0.0/lib/pure/asyncmacro.nim(311)   dispatch
    /home/juan/.choosenim/toolchains/nim-1.0.0/lib/pure/asyncmacro.nim(37)    dispatchNimAsyncContinue
    /home/juan/.nimble/pkgs/jester-0.4.3/jester.nim(285)                      dispatchIter
    /home/juan/.choosenim/toolchains/nim-1.0.0/lib/pure/asyncfutures.nim(383) read
  ]#
Exception message: /home/juan/code/temp2/example.nim(13, 12) `@"username" == "somevalue"`
  • @"key" is broken
@dom96

This comment has been minimized.

Copy link
Owner

commented Oct 4, 2019

What is it equal to?

@juancarlospaco

This comment has been minimized.

Copy link
Author

commented Oct 4, 2019

Empty string always for everything, is shown on the example too (the assert message).

@hokamoto

This comment has been minimized.

Copy link

commented Oct 6, 2019

I added resp "ok" to suppress an inrrevant exception.

post "/dologin":
  assert @"username" == "somevalue", @"username"
  resp "ok"

Then, I got 200 OK.

$ curl -v -d 'username=somevalue' http://127.0.0.1:5000/dologin
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 5000 (#0)
> POST /dologin HTTP/1.1
> Host: 127.0.0.1:5000
> User-Agent: curl/7.54.0
> Accept: */*
> Content-Length: 18
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 18 out of 18 bytes
< HTTP/1.1 200 OK
< Content-Length: 2
< Server: HttpBeast
< Date: Sun, 06 Oct 2019 02:09:27 GMT
< Content-Type: text/html;charset=utf-8
<
* Connection #0 to host 127.0.0.1 left intact
ok
@juancarlospaco

This comment has been minimized.

Copy link
Author

commented Oct 6, 2019

Same Error, I added resp @"username".

$ curl -v -d 'username=somevalue' http://127.0.0.1:5000/dologin

*   Trying 127.0.0.1:5000...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 5000 (#0)
> POST /dologin HTTP/1.1
> Host: 127.0.0.1:5000
> User-Agent: curl/7.66.0
> Accept: */*
> Content-Length: 18
> Content-Type: application/x-www-form-urlencoded
> 
* upload completely sent off: 18 out of 18 bytes
* Mark bundle as not supporting multiuse
< HTTP/1.1 502 Bad Gateway
< Content-Length: 5846
< Server: HttpBeast
< Date: Sun, 06 Oct 2019 02:59:50 GMT
< Content-Type: text/html;charset=utf-8
< 
* Connection #0 to host 127.0.0.1 left intact
@hokamoto

This comment has been minimized.

Copy link

commented Oct 6, 2019

I tried it on my Mac and on a Linux server, and then it worked on both env. I have no idea about the root cause, but I'm sharing my env for your information...

Mac

$ nim -v
Nim Compiler Version 1.0.0 [MacOSX: amd64]
Compiled at 2019-09-23
Copyright (c) 2006-2019 by Andreas Rumpf

git hash: f7a8fc46c0012033917582eb740dc0343c093e35
active boot switches: -d:release

$ nimble list -i
asynctools  [#pr_fix_compilation]
c2nim  [0.9.14]
httpbeast  [0.2.2]
jester  [0.4.3]

Linux

$ nim -v
Nim Compiler Version 0.20.2 [Linux: amd64]
Compiled at 2019-07-17
Copyright (c) 2006-2019 by Andreas Rumpf

active boot switches: -d:release

$ nimble list -i
asynctools  [#pr_fix_compilation]
c2nim  [0.9.14]
httpbeast  [0.2.2]
jester  [0.4.3]
@juancarlospaco

This comment has been minimized.

Copy link
Author

commented Oct 6, 2019

Your version of Nim is 0.20.2. @hokamoto

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.