jsonclojuretransit

java.io.EOFException when parsing JSON with clojure Transit


I am reading from an input stream with (t/read request-body :json) and I get a java.lang.RuntimeException: java.io.EOFException.

{"A":"B", "C":"D"}
java.lang.RuntimeException: java.io.EOFException
                   ReaderFactory.java:122 com.cognitect.transit.impl.ReaderFactory$ReaderImpl.read
                  TransitFactory.java:136 com.cognitect.transit.TransitFactory$DeferredJsonReader.read
                          transit.clj:285 cognitect.transit/read

Any ideas why this could be?

For clarity the curl POST request:

%curl -X POST ...../word -H "Content-Type: application/json" -d '{"A":"B", "C":"D"}' -v > abc.html 
* Hostname was NOT found in DNS cache
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:--     --:--:--     0*   Trying 178.63.65.149...
* Connected to ..... (178.63.65.149) port 80 (#0)
> POST /word HTTP/1.1
> User-Agent: curl/7.37.1
> Host: .....
> Accept: */*
> Content-Type: application/json
> Content-Length: 18
> 
} [data not shown]
* upload completely sent off: 18 out of 18 bytes
< HTTP/1.1 500 Server Error
* Server nginx/1.2.1 is not blacklisted
< Server: nginx/1.2.1
< Date: Sat, 04 Apr 2015 19:05:03 GMT
< Content-Type: text/html;charset=ISO-8859-1
< Content-Length: 13190
< Connection: keep-alive
< 
{ [data not shown]
100 13208  100 13190  100    18  79062    107 --:--:-- --:--:-- --:--:-- 79457
* Connection #0 to host ..... left intact


Solution

  • Looking at your logging data, your request body is not actually json, it looks like a multi-part/form-data encoded form which includes a json file-upload.