users@grizzly.java.net

Need help with Grizzly-based HTTP client

From: Jon Brisbin <jon_at_jbrisbin.com>
Date: Mon, 11 Jul 2011 17:59:51 -0500 (CDT)

I'm working on a non-blocking HTTP client based on Grizzly and I'm having trouble figuring out what I'm doing wrong in my "upload" test.

The source is on github:

https://github.com/jbrisbin/grizzly-http-client

The test I'm having trouble with looks like:

def "Test upload file"() {

given:
FileChannel input = new RandomAccessFile("src/test/files/lorem_ipsum.txt", "r").channel

when:
Request req = PUT("http://localhost:8098/riak/upload/text")
req.contentType = "text/plain"
req.contentLength = input.size()
WritableByteChannel w = req.start()
input.transferTo(0, input.size(), w)
Response resp = await req.complete()

then:
resp.status == 204

}

I'm using the FileChannel.transferTo() to stream a file from the filesystem to a local Riak server. It looks like its sending more data than what I'm supposed to, though, because I end up getting an additional response back from the server I'm not expecting. Like I'm sending all the content I'm supposed to for the initial request, but there's extra data somewhere that Riak is interpreting as a new request. But it's not a "real" request, so it naturally is giving an error response to the filter, which isn't expecting a response from the server, so throws an exception. Clear as mud? :)

The request seems to succeed and all the data I'm expecting to see in that entry is there. It seems like I'm just sending *more* data than I'm supposed to.

Any help here would be greatly appreciated! :)

Thanks!

Jon Brisbin
http//jbrisbin.com