mkovatsc / Copper

Copper (Cu) CoAP user-agent (JavaScript implementation)

Home Page:http://people.inf.ethz.ch/mkovatsc/copper.php

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Automatic block-wise transfer for PUT/POST

dalessan opened this issue · comments

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?

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.

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

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...

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

I have just two minor remarks:

  • In PUT/POST requests Block1 option is used even when the payload is smaller than the block size. Even if that may be allowed by the block-wise transfer draft (not sure, I haven't checked), I think it would be better to avoid using block-wise transfer when not necessary.
  • I think it would be better to always send plain GET requests (i.e., without Block2 option) and let the server decide if block-wise must be used and with which size (basically, revert to the previous behavior for GET requests). The only reason I can think of for using early negotiation in Copper is to test the server implementation, but that can (should?) be done using Debug option.

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

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.

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...

I should have the latest version (my HEAD is at efee0d0). 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.

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.

Great! It works now :)