Skip to content
This repository has been archived by the owner on Feb 14, 2023. It is now read-only.

HTTPS/TLS support #98

Open
nappa85 opened this issue Jan 30, 2018 · 5 comments
Open

HTTPS/TLS support #98

nappa85 opened this issue Jan 30, 2018 · 5 comments

Comments

@nappa85
Copy link

nappa85 commented Jan 30, 2018

I know it's not an issue directly connected to multipart, but it's chain's closing ring...

I need to send a multipart/form-data submit to an https address, I searched for a working example without luck, so I tried to merge different examples from hyper_native_tls and multipart.
I haven't beed able to find a method to specify a call method (GET, POST, PUT, ecc...).

You can find my code here: https://github.com/nappa85/Rustegram/blob/master/client_lib/src/lib.rs
The test is everything you need to make it work, or fail, because it fails with
thread 'tests::it_works' panicked at 'Error sending multipart request: Io(Error { repr: Custom(Custom { kind: WriteZero, error: StringError("failed to write whole buffer") }) })', src/libcore/result.rs:906:4

Maybe my code could be helpful to create a working example about multipart over HTTPS

@abonander
Copy link
Owner

Multipart is done exclusively with the POST verb. This is handled in Multipart::client_request(). As far as I can tell, your usage is correct; the error is coming from a write() call that returns zero bytes written from a non-empty buffer (I assume it's a non-empty buffer, if not that's a bug in Multipart).

@abonander
Copy link
Owner

Okay, I've run your test and gotten the error but there's something I don't understand. The only occurrence of that error string is src/server/save.rs which is the wrong side of the API. I'm not sure what's going on here.

@abonander
Copy link
Owner

Ah, I see, it also occurs in the Write impl for &mut [u8]. It's when the slice is smaller than the input data, which is... not optimal.

@abonander
Copy link
Owner

I stepped through this with a debugger and it doesn't seem to be Multipart's fault. The error occurs when trying to write to the network stream, after io::copy() has read all of PreparedFields's data to a buffer on the stack. This may be an issue with hyper-native-tls, I don't know.

@nappa85
Copy link
Author

nappa85 commented Jan 31, 2018

Thank you very much for your support.
I've tried every version of hyper-native-tls released so far and the problem doesn't change, I'll look deeper into it asap, in the meanwhile I started looking into your multipart-async, maybe I can help you on it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants