mkovatsc / Copper

Copper (Cu) CoAP user-agent (JavaScript implementation)
http://people.inf.ethz.ch/mkovatsc/copper.php
BSD 3-Clause "New" or "Revised" License
94 stars 43 forks source link

Automatic block-wise transfer for PUT/POST #3

Closed dalessan closed 11 years ago

dalessan commented 11 years ago

I noticed that block-wise transfer is not used with PUT/POST requests even if the payload is larger than the block size specified in the "Behavior" drop-down menu. The only way to use block-wise transfer in PUT/POST requests is to enable "Debug options" and sets the "Block1" field to 0.

Am I missing something here? If not, would it be possible to have automatic block-wise transfer for PUT/POST requests in future Copper releases?

mkovatsc commented 11 years ago

Good point. I guess, I will change the Behavior (including menu) so that either no Blocks or the specified Block size is used for each request/response.

dalessan commented 11 years ago

Thank you :) The solution you propose would be perfect.

mkovatsc commented 11 years ago

I just pushed an update that introduces the new behavior. As there are now quite some configuration dependencies, it would be cool if you could test this a bit...

dalessan commented 11 years ago

Thank you very much for your fix. I tested it and it seems to work well :)

I have just two minor remarks:

Anyway, these are just minor issues and I am more than happy with the current fix. Thank you again :+1:

dalessan commented 11 years ago

I think I just found a bug in the latest update. When Block late negotiation is selected, discovery does not wok if the server uses block-wise transfer. Indeed, when clicking on Discovery, the following happens:

  1. Copper sends a GET request to /.well-known/core without the Block2 option
  2. The server replies with a Block2 option with block no. equal to 0.
  3. Copper sends another GET request to /.well-known/core with the Block2 option, but with an Option Length equal to 0. At this point the systems enters a loop, since the server re-sends the first block.

Interestingly enough, the problem does not happen if I explicitly send a GET request to /.well-known/core, instead of clicking the Discovery button.

mkovatsc commented 11 years ago

Have you done a pull after the first change? I improved the block size negotiation, so that the negotiated size will be selected in the Behavior menu. For me, Discover works just fine...

dalessan commented 11 years ago

I should have the latest version (my HEAD is at efee0d05c9). Indeed, when I issue a GET request the block size is automatically set to the negotiated one. However, if I choose Block late negotiation and then I click Discovery, the discovery does not work for me :/ I also tried to reset Copper configuration. I am probably doing something wrong... I will try to figure that out. Sorry for bothering you.

mkovatsc commented 11 years ago

I forgot to push the latest update. Do a pull now, it should fix the issue. Keep reporting! It is good to have testers, as I have not enough man-power for all the projects at the moment.

dalessan commented 11 years ago

Great! It works now :)