-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support a request body that's not a string #41
Comments
Hi had, what would you want the body to be? Raw bytes? Fields? (Which do get encoded as a string, bit we could certainly add functions to make that easier.) |
Not always string, sometimes raw bytes like here https://github.com/SuaveIO/suave/blob/master/src/Suave/Web.fs#L216 |
Sorry, haf not 'had' - autocorrect user error! Should be doable, I'll try and have a look this weekend. |
OK, I've put this on github, there's now a withBodyBytes function. The way I've implemented it is a (slightly) breaking change to the API - do you think you'd be able to have a look and see if it meets your needs, before I make a NuGet from it? |
Yes, sure - but perhaps you could see if the API matches; the change I'd need is to make these lines: https://github.com/SuaveIO/suave/blob/master/src/Suave.Testing/Testing.fs#L123-L190 work with Http.fs - and as a side-effect you would test almost the full implementation of Http.fs. |
I'll give it a look if I get the chance - having problems getting the build system working on my work PC. One thing is the timeout, which there's currently no way to set with Http.fs, but would be easy to add. |
Hi, Something like:
|
Hi @Muhomorik, yes that would be pretty easy to add. I'm not sure about the name, but I can't think of a better one and it matches 'withQueryStringItem'. I'd be tempted to default the content type to x-www-form-urlencoded, but that would be confusing if someone had set the content type earlier, and there might be situations where people don't want to set it. Perhaps best just let the user set it as per your example. If you want to have a crack at it and send me a PR go for it, otherwise I'll add it when I can, won't be for at least a week or so though. |
@relentless Not setting content type sends request anyway, so maybe a good idea to leave to the user. |
Would be great to also have an interface for adding files to the request, beyond just having a body full of bytes. Otherwise I'd have to write the file encoding myself, as well as the boundary in the form. |
I've browsed the code a bit, and I'm not sure it's a good idea to flush the body when you use Would be better to have a ByteBody and a StreamBody as possible values to set to your Request object, so that I can re-use the request object and also be very specific about when I want the data to be 'used'/stream disposed. |
Something like this
|
Closing in favour of #65 and related child-issues. |
Title says it all...
The text was updated successfully, but these errors were encountered: