0

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

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

thanks, I changed the post request's type using curl and updated the question accordingly
OK that looks better. Note that you can read a request body only once. If your code prints the body for debugging and then tries to read it again for parsing that will give an EOF error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.