Jumoo / uSync.Complete.Issues

Public Issue tracker and roadmap for uSync.Complete
https://jumoo.co.uk/usync/complete/
2 stars 1 forks source link

Middleware body stream protection #146

Closed KevinJump closed 2 years ago

KevinJump commented 2 years ago

(this has not been reported as an issue - but in theory it might become one as more people configure their Umbraco sites)

by default the request body stream in .net core is one way readonly, and cannot be re-set (e.g you can't read it twice!).

internally in uSync.Complete we need to read the buffer when files are sent between sites, and this works, but if some middleware is configured on teh site that reads the body stream requests this will fail. (and there is not much we can do about that!).

the best practice if middleware does read the stream is to replace the body stream with a seekable stream. if this is done then we can reset the stream before reading it.

this update adds a check at the start of the methods that read the stream, to see if the body stream is seekable, if it is , we seek back to the start - making a failure a little less likely.