From: Nelson, E. - 2 <eri...@ba...> - 2010-02-09 22:53:02
|
Is there any reason I can't send a binary response? For example, the hello_world_server has response = server::response::stock_reply(server::response::ok, "Hello, World!"); Could I fill a string with binary data and send it like this? String s("\0\0\0\0\0") response = server::response::stock_reply(server::response::ok, s); and get it out on the client side? If so, would I use boost::network::body(response) on the client side, or something else? Thanks Erik |
From: Glyn M. <gly...@gm...> - 2010-02-10 09:15:37
|
Hi Erik, On 9 February 2010 23:52, Nelson, Erik - 2 <eri...@ba...>wrote: > Is there any reason I can't send a binary response? > > For example, the hello_world_server has > > response = server::response::stock_reply(server::response::ok, "Hello, > World!"); > > Could I fill a string with binary data and send it like this? > > String s("\0\0\0\0\0") > response = server::response::stock_reply(server::response::ok, s); > > and get it out on the client side? If so, would I use > boost::network::body(response) on the client side, or something else? > You'd have to base 64 encode and decode any binary data in HTTP. There's nothing in cpp-netlib which does this, but you can use: https://svn.boost.org/trac/boost/browser/trunk/boost/archive/iterators/base64_from_binary.hpp before copying your data to the message on the server and. https://svn.boost.org/trac/boost/browser/trunk/boost/archive/iterators/binary_from_base64.hpp for the client. HTH, Glyn |
From: Nelson, E. - 2 <eri...@ba...> - 2010-02-12 22:16:51
|
From: Glyn Matthews [mailto:gly...@gm...] Sent: Wednesday, February 10, 2010 4:16 AM > You'd have to base 64 encode and decode any binary data in HTTP. There's nothing in cpp-netlib which does this, but you can use: Thanks for the response... I have the base64 functions, but was hoping to avoid the overhead. Are all binary transfers handled this way? For example, when I download a binary file from Sourceforge, is it base64 encoded on the wire? Erik |
From: Glyn M. <gly...@gm...> - 2010-02-13 07:53:41
|
Hi Erik, On 12 February 2010 22:36, Nelson, Erik - 2 <eri...@ba... > wrote: > *From:* Glyn Matthews [mailto:gly...@gm...] > *Sent:* Wednesday, February 10, 2010 4:16 AM > > You'd have to base 64 encode and decode any binary data in HTTP. > There's nothing in cpp-netlib which does this, but you can use: > > Thanks for the response... I have the base64 functions, but was hoping to > avoid the overhead. Are all binary transfers handled this way? For > example, when I download a binary file from Sourceforge, is it base64 > encoded on the wire? > Yes, if you download it using HTTP all binary data needs to be MIME encoded. G |
From: Leon M. <l.p...@so...> - 2010-02-16 19:40:11
|
On Sat, Feb 13, 2010 at 8:53 AM, Glyn Matthews <gly...@gm...>wrote: > *From:* Glyn Matthews [mailto:gly...@gm...] >> *Sent:* Wednesday, February 10, 2010 4:16 AM >> > You'd have to base 64 encode and decode any binary data in HTTP. >> There's nothing in cpp-netlib which does this, but you can use: >> >> Thanks for the response... I have the base64 functions, but was hoping to >> avoid the overhead. Are all binary transfers handled this way? For >> example, when I download a binary file from Sourceforge, is it base64 >> encoded on the wire? >> > > Yes, if you download it using HTTP all binary data needs to be MIME > encoded. > On 12 February 2010 22:36, Nelson, Erik - 2 < > eri...@ba...> wrote: > Sorry to interrupt, but is this true? I always thought the HTTP Context-Length: response parameter was invented for this purpose, to be able to transfer raw binary data. -- Leon Mergen |
From: Nelson, E. - 2 <eri...@ba...> - 2010-02-16 19:58:08
|
From: Leon Mergen >>On Sat, Feb 13, 2010 at 8:53 AM, Glyn Matthews >>Yes, if you download it using HTTP all binary data needs to be MIME encoded. > Sorry to interrupt, but is this true? I always thought the HTTP Context-Length: response parameter was invented for this purpose, to be able to transfer raw binary data. I thought it was possible, since Content-Length can be specified, and with chunked transfer each chunk has a byte count associated with it. http://www.jmarshall.com/easy/http/#structure http://www.jmarshall.com/easy/http/#http1.1c2 I would be a little surprised if every jpeg being shipped around the net was being converted to/from base64 with every transfer... seems like it would be a ton of overhead. That being said, I'm no expert in this field, and I don't know what the plan for cpp-netlib is in this area. Erik |
From: Dean M. B. <mik...@gm...> - 2010-02-16 20:16:18
|
Hi Guys, On Wed, Feb 17, 2010 at 3:57 AM, Nelson, Erik - 2 <eri...@ba...> wrote: > > From: Leon Mergen > > >>On Sat, Feb 13, 2010 at 8:53 AM, Glyn Matthews > >>Yes, if you download it using HTTP all binary data needs to be MIME encoded. > > > Sorry to interrupt, but is this true? I always thought the HTTP Context-Length: response parameter was invented for this purpose, to be able to transfer raw binary data. > > I thought it was possible, since Content-Length can be specified, and with chunked transfer each chunk has a byte count associated with it. > Yes, it is possible. You can already use the cpp-netlib client to download in HTTP 1.0 mode binary data -- there are even tests packaged in the library to prove it. > > I would be a little surprised if every jpeg being shipped around the net was being converted to/from base64 with every transfer... seems like it would be a ton of overhead. > > That being said, I'm no expert in this field, and I don't know what the plan for cpp-netlib is in this area. > The plan is to keep cpp-netlib as it is right now able to handle binary data (of course transferred in the appropriate network byte order) as it comes over the wire. Have you encountered a bug that's not allowing you to download binary data using the HTTP client? -- Dean Michael Berris cplusplus-soup.com | twitter.com/deanberris linkedin.com/in/mikhailberis | facebook.com/dean.berris | deanberris.com |
From: Divye K. <div...@gm...> - 2010-02-17 07:44:28
|
Hello everyone, Been a long time and I've been busy with my acads, but I had a contribution I had to make to this discussion: On Wed, Feb 17, 2010 at 1:45 AM, Dean Michael Berris <mik...@gm... > wrote: > > Yes, it is possible. You can already use the cpp-netlib client to > download in HTTP 1.0 mode binary data -- there are even tests packaged > in the library to prove it. > <snip> > The plan is to keep cpp-netlib as it is right now able to handle > binary data (of course transferred in the appropriate network byte > order) as it comes over the wire. > > I'm not so sure that byte conversion is being performed or being tested by the library. The tests do not specifically check for byte conversion issues as they are being run on the same host. The tests simply check that binary data is transferred "as-is" between server and client and that the end result is the same file data. Byte order tests are still missing I guess. Dean might be able to throw light on the library implementation of the byte order conversion issues. @Erik: The binary transfer test is libs/network/test/http_localhost_tests.cpp - binary_file_query Divye -- Life is complicated. Its that simple! |
From: Nelson, E. - 2 <eri...@ba...> - 2010-02-16 20:26:40
|
>From Dean Michael Berris on Tuesday, February 16, 2010 3:16 PM >Yes, it is possible. You can already use the cpp-netlib client to download in HTTP 1.0 mode binary data -- there are even tests packaged in the library to prove it. That's great! Does it work from the server side, too? Are there plans for HTTP 1.1 support? >Have you encountered a bug that's not allowing you to download binary data using the HTTP client? Not at all... I was just trying to understand what was possible- here's my original question **************************** Is there any reason I can't send a binary response? For example, the hello_world_server has response = server::response::stock_reply(server::response::ok, "Hello, World!"); Could I fill a string with binary data and send it like this? String s("\0\0\0\0\0") response = server::response::stock_reply(server::response::ok, s); and get it out on the client side? If so, would I use boost::network::body(response) on the client side, or something else? ******************************** I haven't actually tried it- can you comment on the original question? I poked around in the tests but didn't find the test that has an example of binary transfer. Thanks Erik |
From: Dean M. B. <mik...@gm...> - 2010-02-16 20:35:45
|
On Wed, Feb 17, 2010 at 4:26 AM, Nelson, Erik - 2 <eri...@ba...> wrote: > >From Dean Michael Berris on Tuesday, February 16, 2010 3:16 PM > >>Yes, it is possible. You can already use the cpp-netlib client to > download in HTTP 1.0 mode binary data -- there are even tests packaged > in the library to prove it. > > That's great! Does it work from the server side, too? Are there plans > for HTTP 1.1 support? > On the server side, HTTP 1.1 support I'm scheduling for 0.7 -- it might make it into 0.6 *if* I find the time to implement it. :D >>Have you encountered a bug that's not allowing you to download binary > data using the HTTP client? > > Not at all... I was just trying to understand what was possible- here's > my original question > OK. :) > > > **************************** > Is there any reason I can't send a binary response? > > For example, the hello_world_server has > > response = server::response::stock_reply(server::response::ok, "Hello, > World!"); > > Could I fill a string with binary data and send it like this? > > String s("\0\0\0\0\0") > response = server::response::stock_reply(server::response::ok, s); > > and get it out on the client side? If so, would I use > boost::network::body(response) on the client side, or something else? > ******************************** > > > I haven't actually tried it- can you comment on the original question? > I poked around in the tests but didn't find the test that has an example > of binary transfer. > Ah, on the server side there's nothing stopping you from doing that. Having used this to do just that, I can tell you with confidence that there's no problem in that regard. :D > Thanks I hope this helps. If you find any glaring bugs please don't hesitate to let us know. :D -- Dean Michael Berris cplusplus-soup.com | twitter.com/deanberris linkedin.com/in/mikhailberis | facebook.com/dean.berris | deanberris.com |
From: Nelson, E. - 2 <eri...@ba...> - 2010-02-16 21:04:15
|
>From Dean Michael Berris Tuesday, February 16, 2010 3:35 PM >Ah, on the server side there's nothing stopping you from doing that. >Having used this to do just that, I can tell you with confidence that there's no problem in that regard. :D If I use boost.serialization to make binary archives (assuming I'm controlling both the client and the server) I won't be able to ship those around okay? E.g., I always will lose the high bit of each byte in the binary buffer? Erik |