Skip to content

Commit

Permalink
Only parse response to lxml if content-type is application/xml.
Browse files Browse the repository at this point in the history
Change-Id: I462d6c0e69181dda883db58c42db065534a2edad
Reviewed-on: https://gerrit.franz.com:9080/3211
Reviewed-by: Ahmon Dancy <dancy@franz.com>
Reviewed-by: John O'Rourke <jor@franz.com>
Tested-by: Kevin Layer <layer@franz.com>
  • Loading branch information
Mikel Bancroft authored and dklayer committed Jul 8, 2013
1 parent 8cf04fa commit 5a68fa0
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions solr.lisp
Expand Up @@ -345,11 +345,16 @@ query by :rows parameter:

;; Parse response
(defun parse-response (body status headers)
(let ((lxml (let ((*package* (find-package :keyword))) (parse-xml body))))
(when (not (eql status 200))
(error 'solr-error :status-code status :response-headers headers
:response-body lxml))
lxml))
(destructuring-bind ((param content-type &optional charset))
(net.aserve::parse-header-value (cdr (assoc :content-type headers)))
(declare (ignore param charset))
(let ((lxml (if* (string-equal content-type "application/xml")
then (let ((*package* (find-package :keyword))) (parse-xml body))
else body)))
(when (not (eql status 200))
(error 'solr-error :status-code status :response-headers headers
:response-body lxml))
lxml)))

;; Some Solr POST message can take optional parameters via url query string.
;; We can't use :query argument of do-http-request, for we have to use
Expand Down

0 comments on commit 5a68fa0

Please sign in to comment.