.. so strange .. here it still fails. I will dive more into the HTTP client to see why it is failing (trying a retry?).
Will followup later!
- Aukjan
Finally got a chance to do real debugging.. Turned out to be a problem with authorization. This was not implemented
(yet) for this resource, causing some errors. Strange though, that I did not get the 401 back, but got the 'Cannot retry
non-repeatable request' (see below in the trace)
Thanks again for your help....
- Aukjan
DEBUG [org.apache.http.headers] << HTTP/1.1 401 Unauthorized
DEBUG [org.apache.http.headers] << WWW-Authenticate: basic realm="Login"
DEBUG [org.apache.http.headers] << Cache-Control: must-revalidate,no-cache,no-store
DEBUG [org.apache.http.headers] << Content-Type: text/html;charset=ISO-8859-1
DEBUG [org.apache.http.headers] << Content-Length: 1278
DEBUG [org.apache.http.headers] << Server: Jetty(7.3.1.v20110307)
DEBUG [org.apache.http.impl.client.DefaultHttpClient] Connection can be kept alive indefinitely
DEBUG [org.apache.http.impl.client.DefaultHttpClient] Target requested authentication
DEBUG [org.apache.http.impl.client.DefaultTargetAuthenticationHandler] Authentication schemes in the order of
preference: [ntlm, digest, basic]
DEBUG [org.apache.http.impl.client.DefaultTargetAuthenticationHandler] Challenge for ntlm authentication scheme not
available
DEBUG [org.apache.http.impl.client.DefaultTargetAuthenticationHandler] Challenge for digest authentication scheme not
available
DEBUG [org.apache.http.impl.client.DefaultTargetAuthenticationHandler] basic authentication scheme selected
DEBUG [org.apache.http.impl.client.DefaultHttpClient] Authorization challenge processed
DEBUG [org.apache.http.impl.client.DefaultHttpClient] Authentication scope: BASIC 'Login'@localhost:9090
DEBUG [org.apache.http.impl.client.DefaultHttpClient] Found credentials
DEBUG [org.apache.http.wire] << "<html>[\n]"
DEBUG [org.apache.http.wire] << "<head>[\n]"
DEBUG [org.apache.http.wire] << "<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>[\n]"
DEBUG [org.apache.http.wire] << "<title>Error 401 Unauthorized</title>[\n]"
DEBUG [org.apache.http.wire] << "</head>[\n]"
DEBUG [org.apache.http.wire] << "<body>[\n]"
DEBUG [org.apache.http.wire] << "<h2>HTTP ERROR: 401</h2>[\n]"
DEBUG [org.apache.http.wire] << "<p>Problem accessing /file/. Reason:[\n]"
DEBUG [org.apache.http.wire] << "<pre> Unauthorized</pre></p>[\n]"
DEBUG [org.apache.http.wire] << "<hr /><i><small>Powered by Jetty://</small></i>[\n]"
DEBUG [org.apache.http.wire] << "</body>[\n]"
DEBUG [org.apache.http.wire] << "</html>[\n]"
DEBUG [org.apache.http.client.protocol.RequestAddCookies] CookieSpec selected: best-match
DEBUG [org.apache.http.impl.client.DefaultHttpClient] Cannot retry non-repeatable request
DEBUG [org.apache.http.impl.conn.DefaultClientConnection] Connection shut down
DEBUG [org.apache.http.impl.conn.SingleClientConnManager] Releasing connection
org.apache.http.impl.conn.SingleClientConnManager$ConnAdapter@6d1e7cc6
On 10/21/11 3:30 PM, Johan Haleby wrote:
> Hi,
>
> I've tried to reproduce the error but it works for me:
>
> byte[] bytes = "somestring".getBytes();
> given().
> contentType("application/octet-stream").
> body(bytes).
> expect().
> statusCode(200).
> when().
> post("/binaryBody");
>
> I've added a test called "requestSpecificationWithContentTypeOctetStreamAllowsSpecifyingBinaryBodyForPost" in
> JSONPostITest
> Have a look at it if you like..
>
> If you're byte array is large you should use multi-part form data uploading
> <http://code.google.com/p/rest-assured/wiki/Usage#Multi-part_form_data> instead.
>
> /Johan
So much more to fix!
Thanks!
- Aukjan
Well.. I do ;) So I am back ..
We finally implemented the security on this resource, so I gave the test a whirl.. But still no dice: (see attached log).
I think the problem lies in the fact that it thinks it is a 'non-repeatable' request, and since in this case you have to
repeat the request due to authentication, it can not do this.
Do you have any suggestion on how to circumvent this?
(BTW I tested this service to be working with other tools (firefox + poster extension))
Thanks!
- Aukjan
I'm not familiar with the term 'non-repeatable request', what does this
mean? Are you using basic authentication? In that case you may want to
try the preemptive basic authentication
(given().auth().preemptive().basic("username", "password"). ..) and see
if it makes any difference.
Regards,
/Johan
But on the 'unbuffered' post... It might be useful to look into this, not only for this instance, but possible future
issues..
Thanks for the pointer!
- Aukjan