dotnet / WatsonWebserver

Watson is the fastest, easiest way to build scalable RESTful web servers and services in C#.
MIT License
411 stars 84 forks source link

ctx.Request.DataAsString ONLY READ 1024 characters (auto cut) #81

Closed mafaza86 closed 2 years ago

mafaza86 commented 2 years ago

Hi everyone, I'm learning to use WatsonWebserver, and I'm having a problem:

That is, when I post hex data that is more than 1024 characters long, only 1024 characters can be accepted.

I use this code to read the data request :

    static async Task PostLogin(HttpContext ctx)
    {
        var data = ctx.Request.DataAsString;

        ctx.Response.StatusCode = 200;
        await ctx.Response.Send("Hello from the POST /login static route! ");
    }

Example of the data I sent (1098 char) : BF382DA43810175E903A4C505EEB488F84B29F0039B21953DCD03918553862B71B74737654AFBD4CFC5665C58A1E08832604BC1B25294BAAC6FB4A08F6756863B6383A38C3CFF1ECCF5B9004DE3C9C5582E4D240FFBD79D00604ABB163289BFD26395DA28F4507705834AD95F408076E06A50023611D98D05AAE9B9B2621D4B53CB48B831BEB7F9F4CA6872CA14AED5D73184F50EE6E2BACF4A635FD3DCEB295530379EF72B97269966BDDD3121AF840E1E120565BF3B95D551F39B5697B244D29BD590E8ED514C6276218049DB2A1057311CDD6911C8AAF07E8CC3E14C837640077F10ED31447D1366741AF9FEA29347AF1568FB8329F3AD817580932960B1044B2F3C29BA1FB25988F160E28F94DA924F78B465BD619FEDC50C8B47F0A62EB812FD6027FFEB1D9193BD0DBDCD79CAFD45BB280CD60EC1FB65431A3C30C2FFCEA2C038C7B9FAE8EAB6A0C2E52F296A32A4DA45415A9DB45BEF41CBA6B78D17BD17E847467F021B3F3348CD4325FB4FDF5E11E58EA2E1499E2C7A5792A177B7DFC6E59851BA94FA0504602292CFBC2BF67342988BBAC54E9EB7D517B9D923E4B196B2BB816D6B80553EFB65CF7F749B21E83159544405CFF8BDDD78388E1A022D7E0D8768A7A2C0DC214E325ED5FC3D0CB175F90D78B68698517EB4BAAE672E5400A4B03232FB4E629042D6F829EAEA6ADA91E2060C8FF80F104CC7143C072F7F6609E0619720495595957B323BDF5E318A6A167F2B2CDD58BC643BEEFFBAAE9C8C6767A4F

received data (1024 char): BF382DA43810175E903A4C505EEB488F84B29F0039B21953DCD03918553862B71B74737654AFBD4CFC5665C58A1E08832604BC1B25294BAAC6FB4A08F6756863B6383A38C3CFF1ECCF5B9004DE3C9C5582E4D240FFBD79D00604ABB163289BFD26395DA28F4507705834AD95F408076E06A50023611D98D05AAE9B9B2621D4B53CB48B831BEB7F9F4CA6872CA14AED5D73184F50EE6E2BACF4A635FD3DCEB295530379EF72B97269966BDDD3121AF840E1E120565BF3B95D551F39B5697B244D29BD590E8ED514C6276218049DB2A1057311CDD6911C8AAF07E8CC3E14C837640077F10ED31447D1366741AF9FEA29347AF1568FB8329F3AD817580932960B1044B2F3C29BA1FB25988F160E28F94DA924F78B465BD619FEDC50C8B47F0A62EB812FD6027FFEB1D9193BD0DBDCD79CAFD45BB280CD60EC1FB65431A3C30C2FFCEA2C038C7B9FAE8EAB6A0C2E52F296A32A4DA45415A9DB45BEF41CBA6B78D17BD17E847467F021B3F3348CD4325FB4FDF5E11E58EA2E1499E2C7A5792A177B7DFC6E59851BA94FA0504602292CFBC2BF67342988BBAC54E9EB7D517B9D923E4B196B2BB816D6B80553EFB65CF7F749B21E83159544405CFF8BDDD78388E1A022D7E0D8768A7A2C0DC214E325ED5FC3D0CB175F90D78B68698517EB4BAAE672E5400A4B03232FB4E629042D6F829EAEA6ADA91E2060C8FF80F104CC7143C072F7

missing data (74 char): F6609E0619720495595957B323BDF5E318A6A167F2B2CDD58BC643BEEFFBAAE9C8C6767A4F

Can anyone help or provide a solution, thanks a lot

jchristn commented 2 years ago

What is the value of the content-length header?

mafaza86 commented 2 years ago

What is the value of the content-length header?

image

I didn't specify the length in the header, sorry I thought it was automatic, I did a test with the Postman application.

Is it necessary to specify the content-length header of each request?

mafaza86 commented 2 years ago

Thank you @jchristn Problem solved by set the Headers Content-Length value