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

This fix makes response header accessible throught condition object #22

Merged
merged 1 commit into from
Aug 16, 2016

Conversation

svetlyak40wt
Copy link
Contributor

Consider this example:

(defun handle-condition (cond)
  (format t "Response Headers Should Not Be Nil: ~A~%" (dex:response-headers cond))
  (dex:ignore-and-continue cond))


(handler-bind ((dex:http-request-failed #'handle-condition))
  (dex:get "http://httpbin.org/status/418" :verbose 1))

It will print "Response Headers Should Not Be Nil: NIL" without this fix and will output response headers when patch applied.

Don't know how to run tests, probably this should be added to the testsuite.

Consider this example:
```
(defun handle-condition (cond)
  (format t "Response Headers Should Not Be Nil: ~A~%" (dex:response-headers cond))
  (dex:ignore-and-continue cond))


(handler-bind ((dex:http-request-failed #'handle-condition))
  (dex:get "http://httpbin.org/status/418" :verbose 1))
```

It will print "Response Headers Should Not Be Nil: NIL" without this fix and will output response headers when patch applied.

Don't know how to run tests, probably this should be added to the testsuite.
@svetlyak40wt svetlyak40wt changed the title This fix makes response header accessible throught codition object This fix makes response header accessible throught condition object Aug 15, 2016
@coveralls
Copy link

coveralls commented Aug 15, 2016

Coverage Status

Coverage decreased (-0.2%) to 75.053% when pulling 559e43d on svetlyak40wt:patch-1 into e5b756d on fukamachi:master.

@fukamachi
Copy link
Owner

Thank you for pointing out!

@fukamachi fukamachi merged commit d1fe8c3 into fukamachi:master Aug 16, 2016
@svetlyak40wt
Copy link
Contributor Author

By the way, I found how to run tests and added few lines:

diff --git a/t/dexador.lisp b/t/dexador.lisp
index c060849..f23e0bd 100644
--- a/t/dexador.lisp
+++ b/t/dexador.lisp
@@ -184,10 +184,21 @@ body: \"Within a couple weeks of learning Lisp I found programming in any other
         (fail "Must raise an error DEX:HTTP-REQUEST-FAILED"))
     (dex:http-request-failed (e)
       (pass "Raise DEX:HTTP-REQUEST-FAILED error")
+      (isnt (dex:response-headers e) nil
+          "response headers is some hash")
       (is (dex:response-status e) 500
           "response status is 500")
       (is (dex:response-body e) "Internal Server Error"
           "response body is \"Internal Server Error\"")))
+
+  (handler-bind ((dex:http-request-failed
+                  (lambda (cond)
+                    (isnt (dex:response-headers cond) nil
+                          "condition's headers is not nil"))))
+    (progn
+        (dex:get (localhost))
+        (fail "Must raise an error DEX:HTTP-REQUEST-FAILED with some headers")))
+
   (handler-case
       (progn
         (dex:get (localhost "/404"))

But even with the patch, they fail with this strange error:

HTTP request failed
    ✓ Raise DEX:HTTP-REQUEST-FAILED error
    ✓ response headers is some hash
    ✓ response status is 500
    ✓ response body is "Internal Server Error"
    ✓ condition's headers is not nil
    × Aborted due to an error in subtest "HTTP request failed"
      Raised an error An HTTP request to "http://localhost:50476/" returned 500 internal server error.

Internal Server Error (expected: :NON-ERROR)

The line "condition's headers is not nil" has good checkmark. Why there is an error after it?

fukamachi added a commit that referenced this pull request Sep 2, 2016
fukamachi added a commit that referenced this pull request Sep 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants