fukamachi / dexador

A fast HTTP client for Common Lisp
http://ultra.wikia.com/wiki/Dexador
377 stars 42 forks source link

new version broke dexador on ubuntu 18.04 #73

Closed jnc-nj closed 5 years ago

jnc-nj commented 5 years ago

Service

(defhandler (app "/" :method :get)
    "quack quack i'm a server.")

Curl

curl 127.0.0.1:9001
--> 
{"message": "quack quack i'm a server."}

Drakma

(drakma:http-request "http://127.0.0.1:9001/" :method :get)
-->
#(123 34 109 101 115 115 97 103 101 34 58 32 34 113 117 97 99 107 32 113 117 97
  99 107 32 105 39 109 32 97 32 115 101 114 118 101 114 46 34 125)
200
((:DATE . "Wed, 18 Sep 2019 08:01:14 GMT") (:CONTENT-TYPE . "application/json")
 (:TRANSFER-ENCODING . "chunked"))
#<PURI:URI http://127.0.0.1:9001/>
#<FLEXI-STREAMS:FLEXI-IO-STREAM {100679D4C3}>
T
"OK"

Dexador

(dex:get "http://127.0.0.1:9001/")
--> 
An HTTP request to "http://127.0.0.1:9001/" returned 400 bad request.

#(66 97 100 32 82 101 113 117 101 115 116)
   [Condition of type DEXADOR.ERROR:HTTP-REQUEST-BAD-REQUEST]

Restarts:
 0: [RETRY-REQUEST] Retry the same request.
 1: [IGNORE-AND-CONTINUE] Ignore the error and continue.
 2: [RETRY] Retry SLIME REPL evaluation request.
 3: [*ABORT] Return to SLIME's top level.
 4: [ABORT] abort thread (#<THREAD "repl-thread" RUNNING {1004831BC3}>)

Backtrace:
  0: (DEXADOR.ERROR:HTTP-REQUEST-FAILED 400 :BODY #(66 97 100 32 82 101 ...) :HEADERS #<HASH-TABLE :TEST EQUAL :COUNT 3 {1007CA4563}> :URI #<QURI.URI.HTTP:URI-HTTP http://127.0.0.1:9001/> :METHOD :GET)
  1: (DEXADOR.BACKEND.USOCKET:REQUEST #<unavailable argument> :METHOD :GET)
  2: (SB-INT:SIMPLE-EVAL-IN-LEXENV (DEXADOR:GET "http://127.0.0.1:9001/") #<NULL-LEXENV>)
  3: (EVAL (DEXADOR:GET "http://127.0.0.1:9001/"))
  4: (SWANK::EVAL-REGION "(dex:get \"http://127.0.0.1:9001/\") ..)
  5: ((LAMBDA NIL :IN SWANK-REPL::REPL-EVAL))
  6: (SWANK-REPL::TRACK-PACKAGE #<CLOSURE (LAMBDA NIL :IN SWANK-REPL::REPL-EVAL) {1007CA264B}>)
  7: (SWANK::CALL-WITH-RETRY-RESTART "Retry SLIME REPL evaluation request." #<CLOSURE (LAMBDA NIL :IN SWANK-REPL::REPL-EVAL) {1007CA25EB}>)
  8: (SWANK::CALL-WITH-BUFFER-SYNTAX NIL #<CLOSURE (LAMBDA NIL :IN SWANK-REPL::REPL-EVAL) {1007CA25CB}>)
  9: (SWANK-REPL::REPL-EVAL "(dex:get \"http://127.0.0.1:9001/\") ..)
 10: (SB-INT:SIMPLE-EVAL-IN-LEXENV (SWANK-REPL:LISTENER-EVAL "(dex:get \"http://127.0.0.1:9001/\") ..)
 11: (EVAL (SWANK-REPL:LISTENER-EVAL "(dex:get \"http://127.0.0.1:9001/\") ..)
 12: (SWANK:EVAL-FOR-EMACS (SWANK-REPL:LISTENER-EVAL "(dex:get \"http://127.0.0.1:9001/\") ..)
 13: (SWANK::PROCESS-REQUESTS NIL)
 14: ((LAMBDA NIL :IN SWANK::HANDLE-REQUESTS))
 15: ((LAMBDA NIL :IN SWANK::HANDLE-REQUESTS))
 16: (SWANK/SBCL::CALL-WITH-BREAK-HOOK #<FUNCTION SWANK:SWANK-DEBUGGER-HOOK> #<CLOSURE (LAMBDA NIL :IN SWANK::HANDLE-REQUESTS) {10048400FB}>)
 17: ((FLET SWANK/BACKEND:CALL-WITH-DEBUGGER-HOOK :IN "/home/jacknchou/.roswell/lisp/slime/2019.08.13/swank/sbcl.lisp") #<FUNCTION SWANK:SWANK-DEBUGGER-HOOK> #<CLOSURE (LAMBDA NIL :IN SWANK::HANDLE-REQUEST..
 18: (SWANK::CALL-WITH-BINDINGS ((*STANDARD-INPUT* . #<SWANK/GRAY::SLIME-INPUT-STREAM {10047104D3}>)) #<CLOSURE (LAMBDA NIL :IN SWANK::HANDLE-REQUESTS) {100484011B}>)
 19: (SWANK::HANDLE-REQUESTS #<SWANK::MULTITHREADED-CONNECTION {1003D5C763}> NIL)
 20: ((FLET SB-UNIX::BODY :IN SB-THREAD::NEW-LISP-THREAD-TRAMPOLINE))
 21: ((FLET "WITHOUT-INTERRUPTS-BODY-4" :IN SB-THREAD::NEW-LISP-THREAD-TRAMPOLINE))
 22: ((FLET SB-THREAD::WITH-MUTEX-THUNK :IN SB-THREAD::NEW-LISP-THREAD-TRAMPOLINE))
 23: ((FLET "WITHOUT-INTERRUPTS-BODY-1" :IN SB-THREAD::CALL-WITH-MUTEX))
 24: (SB-THREAD::CALL-WITH-MUTEX #<CLOSURE (FLET SB-THREAD::WITH-MUTEX-THUNK :IN SB-THREAD::NEW-LISP-THREAD-TRAMPOLINE) {7FA848B96D7B}> #<SB-THREAD:MUTEX "thread result lock" owner: #<SB-THREAD:THREAD "rep..
 25: (SB-THREAD::NEW-LISP-THREAD-TRAMPOLINE #<SB-THREAD:THREAD "repl-thread" RUNNING {1004831BC3}> NIL #<CLOSURE (LAMBDA NIL :IN SWANK-REPL::SPAWN-REPL-THREAD) {1004831B6B}> NIL)
 26: ("foreign function: call_into_lisp")
 27: ("foreign function: new_thread_trampoline")
jnc-nj commented 5 years ago

Edit:

This is failing with

(defvar *app* (make-instance 'ningle:app))

(setf (ningle:route *app* "/")
      "Welcome to ningle!")

(setf (ningle:route *app* "/login" :method :POST)
      #'(lambda (params)
          (if (authorize (cdr (assoc "username" params :test #'string=))
                         (cdr (assoc "password" params :test #'string=)))
              "Authorized!"
              "Failed...Try again.")))

(clack:clackup *app*)

from https://github.com/fukamachi/ningle as well

* (dex:get "http://127.0.0.1:5000")

debugger invoked on a DEXADOR.ERROR:HTTP-REQUEST-BAD-REQUEST in thread
#<THREAD "main thread" RUNNING {10004F04C3}>:
  An HTTP request to "http://127.0.0.1:5000" returned 400 bad request.

Bad Request

Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [RETRY-REQUEST      ] Retry the same request.
  1: [IGNORE-AND-CONTINUE] Ignore the error and continue.
  2: [ABORT              ] Exit debugger, returning to top level.

(DEXADOR.ERROR:HTTP-REQUEST-FAILED 400 :BODY "Bad Request" :HEADERS #<HASH-TABLE :TEST EQUAL :COUNT 4 {1004337383}> :URI #<QURI.URI.HTTP:URI-HTTP http://127.0.0.1:5000> :METHOD :GET)
   source: (ERROR (GETHASH STATUS *REQUEST-FAILED-ERROR* 'HTTP-REQUEST-FAILED)
                  :BODY BODY :STATUS STATUS :HEADERS HEADERS :URI URI :METHOD
                  METHOD)
0] 
RUNTIME> (clack:clackup *app*)
Hunchentoot server is started.
Listening on 127.0.0.1:5000.
#S(CLACK.HANDLER::HANDLER
   :SERVER :HUNCHENTOOT
   :ACCEPTOR #<SB-THREAD:THREAD "clack-handler-hunchentoot" RUNNING
                {1005804793}>)
[2019-09-18 16:53:32 [WARNING]] Warning while processing connection: The value of STRING is NIL, which is not of type STRING.
WARNING: The value of STRING is NIL, which is not of type STRING.

@fukamachi if you could look into this that would be great, thanks!

fukamachi commented 5 years ago

This is caused with the recent Lack's bug. See https://github.com/fukamachi/lack/issues/39 and try it with the latest Lack.

jnc-nj commented 5 years ago

This is caused with the recent Lack's bug. See fukamachi/lack#39 and try it with the latest Lack.

Can confirm latest commit works, thanks!