-
Notifications
You must be signed in to change notification settings - Fork 377
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
Added a method to perform POST Form Upload #69
Conversation
…coverage and fixed code style.
Thanks for the contribution! It seems like this PR contains some of the changes that were in your other PR already. Can you rebase this onto master and make it only contain the actual related changes please. |
I have no idea how to do that, but I think you can do it more easily on you side: https://github.com/blog/2243-rebase-and-merge-pull-requests Just choose "Rebase and merge" instead of "Merge pull request". Thank you. |
I would love to have a clean PR for reviewing before I merge anything. |
Added TestInvalidProxy test. Reduced a line length to comply with CI rule. Updated README, updated test proxy address, added a test to increase coverage and fixed code style. Added a method to set SSL Key password and added some missing Doxygen headers. Updated an info in README.md
Fixed code indentation to comply with Cpplint. Added web proxy tunneling support. this adds support for using proxies corresponding to the CURLOPT_PROXY and CURLOPT_HTTPPROXYTUNNEL config options in libcurl. closes mrtazz#68 default to 10s timeout in unit tests this makes the conn object in unit tests default to a 10s timeout in order to fail fast if something is up with the connection or configured hosts.
I squashed the commits of Proxy support and POST Form, but I don't know how to clean this PR. git is still obscure for me. |
@embeddedmz no worries, it looks great now. Thanks for the cleanup. I'll take a look at it within the next couple of days. |
Ok this was definitely more than a couple of days. Sorry about that @embeddedmz! I looked over the code and I think it looks great. Given the API and how it's intended to be used, I would prefer I also think accessing it via the Helpers namespace makes the API a little bit weird. |
I ll try to refactor the code according to your advices before the end of this month. |
@embeddedmz @mrtazz is some help needed for this issue? I'm actually looking forward to the 0.5.0 release, mainly because of the SSL security feature. If there is anything I can help with, please tell me. Regards. |
I will work that this weekend, I have time for it. Regards. |
Ok, I'll be here anyway...
Regards.
…On Jun 9, 2017 16:37, "embeddedmz" ***@***.***> wrote:
I will work that this weekend, I have time for it.
Regards.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#69 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AD0gmKAhSqkXeskMGBAwJSsYZa7f3YBIks5sCZ7jgaJpZM4LVSuU>
.
|
@mrtazz I think I made the necessary changes, but the Travis-CI's build is failing for a strange reason... Your feedback is needed to speed things up :) Thanks. |
awesome, I'll take a look. The nightly CI build has started to fail a couple of days ago on master as well, so it might be that the travis config needs a change. |
It seems the fail is related to some coding style definition. From the CI job output:
|
@dfons I ll check that tonight. Thank you. |
@mrtazz It's all good ! please don't tell me to squash commits because last time it was hard for me to do that and I forgot how to do it (unless you give me the commands). |
@embeddedmz no worries. Last time was just about having a clean PR to review. Sorry you had a bad time. I'll review and take care of any squashing before it goes into master. |
@mrtazz Excellent, the description of the unit test is on the top of that page, I used http://posttestserver.com/ to upload a dummy text file, and it still works very great, you can also see the uploaded file... In the URL http://posttestserver.com/data (/[year]/[month]/[day]/restclientcpptests/) the day is related to the time zone of the server, so if you launch the unit test at 14/06/17 - 00:05 (GMT +1) for example, you will find the directory under http://posttestserver.com/data/2017/06/13/restclientcpptests because of the difference in the time zone ! |
@mrtazz What's the ETA we can expect for the release? Do you need some help? If so, do not hesitate in asking me... |
@dfons thanks, I just need to find a bit of time to sit down and read through it. But will let you know! |
Seems like http://posttestserver.com got deprecated in favor of http://ptsv2.com/. So we'll need to update this before we can merge it |
Yes, we will need to create a "toilet" in https://ptsv2.com (e.g. kv6od-1543167696) and send the data to it (e.g. "http://ptsv2.com/t/kv6od-1543167696/post"). What do you think about rule 2.4 in https://ptsv2.com/s/somerules.html ? Your project is popular, I think we will break this rule. |
oh that's a good point. I hadn't seen that. Maybe this will need another integration test setup much like the proxy docker container. |
@mrtazz What's the status of this PR? Honestly I'm using this library and just now I need the |
@@ -53,6 +74,8 @@ Response get(const std::string& url); | |||
Response post(const std::string& url, | |||
const std::string& content_type, | |||
const std::string& data); | |||
Response postForm(const std::string& url, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just use an overload of post()
instead of this newly named function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point
* @brief This class represents the form information to send on | ||
* POST Form requests | ||
*/ | ||
class PostFormInfo { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This name doesn't accurately reflect the notion that a form can be submitted with any HTTP method. Why not just name this FormData
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good.
RestClient::Response RestClient::postForm(const std::string& url, | ||
const PostFormInfo& data) { | ||
RestClient::Response ret; | ||
RestClient::Connection *conn = new RestClient::Connection(""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There shouldn't be any need to use new
; you only need the connection during the lifetime of the function. Just use a stack allocation instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's true. That will allow the remove of a lot of extraneous code and improve performance of RestClient interface. It should be done for all RestClient methods.
time_t rawtime; | ||
tm * timeinfo; | ||
time(&rawtime); | ||
timeinfo = localtime( &rawtime ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The system time is not a reliable way to ensure you have a unique file name. You should just use mkstemp()
to get a unique filepath instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, but it's reliable enough. If it really bugs you, it can be changed. Mostly this needs to run on dev systems on and a clean container that's spun up in CI so no worries there.
Apologies for the fly-by code review. I am interested in using this feature when it eventually merges and was hoping to clean up a few of the rough edges I noticed. Do you need help getting this over the finish line? I'm happy to help if this is simply a matter of finishing known tasks. |
@chpatton013 Thanks for your quick reply. As I noticed there are some tasks for renaming the functions and classes only. yes? So it's not a big task. |
@hamzehnasajpour I'm by no means an authority figure here. I only meant to offer suggestions, not requirements. |
@embeddedmz, I'm a new contributor and I want to see your change get merged. It seemed that @chpatton013 had some good suggestions. Can you please reply to them? I'd like to merge this change in and cut a release soon. You should rebase to get CI to be fixed. Thanks! |
@edwinpjacques I can't really find free time to take care of this, so if someone else wants to take care of it, it doesn't bother me. Regards. |
@embeddedmz OK I will look to resolve the outstanding issue. I will make another PR and close this one. Your feedback on it would be appreciated. Thanks! |
Replaced with #163 |
Some REST platforms (e.g. Symphony) require a POST Form upload in some requests to send data to them. So I added code to perform post form upload.
I created a helper object to wrap HTML form information. Then we pass it to postForm method to perform the upload.
The unit test I wrote uses Henry's HTTP Post dumping server http://posttestserver.com/
The details of the upload of the dummy test file can be found under http://posttestserver.com/data (/[year]/[month]/[day]/restclientcpptests/)
There's no memory leaks.