nim-hyperx
nim-hyperx copied to clipboard
Fix frame payload inconsistencies
Follow up of #25
Current received payload only includes data in case of data frame and field block in case of header, and push promise. Missing optional fields and padding.
Inconsistencies:
- If we ever add padding to sent frames, payload would include the optional field + padding. Received frames do not.
- PayloadLen can be greater than the
payload.lenbecause it includes the optional fields + padding, but payload does not. - The headers table size update requires handling optional fields. Currently it would add them before the optional fields, instead of before the field block. Granted there is no way to add optional fields (pad len, prio) right now, so it's ok.
- A receive frame may include the pad flag, and the priority flag, but the payload is missing these fields.
- Pad field, and priority fields need to be received making their own socket calls.
The biggest issue is using payload.len in places where PayloadLen should be used (ex: flow control).
Downsides:
- Dealing with just payload, without knowing about data / field block is simpler.
- Priority is deprecated, so not handling anything related to priority is ok.
- Headers are decoded and added back to the frame, so there's always going to be inconsistencies.
- Need to remove header padding to append continuations regardless. NOT DONE YET.
Upsides:
- Easy to add the headers table update before field block.
- PayloadLen equal to PayloadSize. Except for decoded headers :(.
- Forces the programmer to be aware of data, field block fragment, and optional fields.
- No inconsistencies between sent and received frames.
- One call to socket receive for the payload. I think this does not really matter because the socket is buffed.
- Can log the complete received frame as is.
Not sure if the added complexity is worth, so I'm trying to come up with something simple here.