How do I get raw request body using servicestack with content-type set to application/x-www-form-urlencoded? -


i have dto

route("/testing","post")] public class testingrequest:irequiresrequeststream {     public stream requeststream { get; set; } } 

and service

public async task<object> post(testingrequest req) {     var rawbody = base.request.getrawbody();     var data = req.requeststream.readfully();     var strdata = utf8encoding.utf8.getstring(data);     ... } 

and found when calling it, rawbody or data not empty if content-type not application/x-www-form-urlencoded. if content type application/x-www-form-urlencoded, rawbody , data empty.

how raw request body whole (string) when caller set content-type application/x-www-form-urlencoded?

my current env ubuntu 16.04 dotnet core 1.1, don't know if matters

servicestack uses forward request stream unless tell servicestack buffer request stream pre-request filter:

prerequestfilters.add((httpreq, httpres) => {     httpreq.usebufferedstream = true; }); 

either servicestack reads or can read having request dtos implement irequiresrequeststream tell servicestack skip reading request body , you're going in services.

application/x-www-form-urlencoded requests special in if irequest.formdata accessed trigger reading request body. can tell servicestack skip reading formdata when creates request with:

setconfig(new hostconfig {     skipformdataincreatingrequest = true }); 

Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -