users@grizzly.java.net

Re: Need help with Grizzly-based HTTP client

From: Jon Brisbin <jon_at_jbrisbin.com>
Date: Tue, 12 Jul 2011 08:38:50 -0500 (CDT)

I think I figured it out. I was actually not zeroing out the content after sending it the first time, so I was sending content a second time but without the headers and such.

Thanks!

Jon Brisbin
http//jbrisbin.com

----- Original Message -----

> From: "Oleksiy Stashok" <oleksiy.stashok_at_oracle.com>
> To: users_at_grizzly.java.net
> Sent: Tuesday, July 12, 2011 6:59:14 AM
> Subject: Re: Need help with Grizzly-based HTTP client

> Hi Jon,

> I'll check it once have time (hopefully later today).
> FYI, Ryan is almost completed Grizzly transport implementation for
> async http client [1]. We hope to have it published soon.

> Thanks.

> WBR,
> Alexey.

> [1] https://github.com/sonatype/async-http-client

> On 07/12/2011 12:59 AM, Jon Brisbin wrote:
> > 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
>