From: Raindog <ra...@ma...> - 2010-12-03 01:42:34
|
Hello, I am wondering if someone can show me a minimalist http post example, at least how to add the query string parameters to the existing example. IE how to post the equivalent of: Http://www.mysite.com/site.cgi?foo=bar&baz=quid Thanks! -- Sent from my Android phone with K-9 Mail. Please excuse my brevity. |
From: Dean M. B. <mik...@gm...> - 2010-12-03 02:50:27
|
Hi, On Fri, Dec 3, 2010 at 9:42 AM, Raindog <ra...@ma...> wrote: > Hello, > > I am wondering if someone can show me a minimalist http post example, at least how to add the query string parameters to the existing example. IE how to post the equivalent of: > > Http://www.mysite.com/site.cgi?foo=bar&baz=quid > Actually this isn't an HTTP POST, but rather an HTTP GET request with the query parameter supplied. This would work for what you intend to do: http::client client; http::client::request request("http://www.mysite.com/site.cgi?foo=bar&baz=quid"); http::client::response response = client.get(request); HTH -- Dean Michael Berris deanberris.com |
From: Raindog <ra...@ma...> - 2010-12-03 03:04:08
|
Thanks, and sorry for the top post, my email client on my phone only supports top posting. I realize now that after your response that I need also to send a file, I am trying essentially to fill out a web form w/ a file upload element, along with some options, hence why I thought it was a POST. I apologize for not being clear "Dean Michael Berris" <mik...@gm...> wrote: >Hi, > >On Fri, Dec 3, 2010 at 9:42 AM, Raindog <ra...@ma...> >wrote: >> Hello, >> >> I am wondering if someone can show me a minimalist http post example, >at least how to add the query string parameters to the existing >example. IE how to post the equivalent of: >> >> Http://www.mysite.com/site.cgi?foo=bar&baz=quid >> > >Actually this isn't an HTTP POST, but rather an HTTP GET request with >the query parameter supplied. This would work for what you intend to >do: > > http::client client; > http::client::request >request("http://www.mysite.com/site.cgi?foo=bar&baz=quid"); > http::client::response response = client.get(request); > >HTH > >-- >Dean Michael Berris >deanberris.com > >------------------------------------------------------------------------------ >Increase Visibility of Your 3D Game App & Earn a Chance To Win $500! >Tap into the largest installed PC base & get more eyes on your game by >optimizing for Intel(R) Graphics Technology. Get started today with the >Intel(R) Software Partner Program. Five $500 cash prizes are up for >grabs. >http://p.sf.net/sfu/intelisp-dev2dev >_______________________________________________ >Cpp-netlib-devel mailing list >Cpp...@li... >https://lists.sourceforge.net/lists/listinfo/cpp-netlib-devel -- Sent from my Android phone with K-9 Mail. Please excuse my brevity. |
From: Dean M. B. <mik...@gm...> - 2010-12-03 03:24:45
|
On Fri, Dec 3, 2010 at 11:04 AM, Raindog <ra...@ma...> wrote: > "Dean Michael Berris" <mik...@gm...> wrote: >> >>Actually this isn't an HTTP POST, but rather an HTTP GET request with >>the query parameter supplied. This would work for what you intend to >>do: >> >> http::client client; >> http::client::request >>request("http://www.mysite.com/site.cgi?foo=bar&baz=quid"); >> http::client::response response = client.get(request); >> >>HTH >> > > I realize now that after your response that I need also to send a file, I am trying essentially to fill out a web form w/ a file upload element, along with some options, hence why I thought it was a POST. I apologize for not being clear > Re-arranging your response for posterity. ;) So even in that situation, instead of using 'client.get' you can use 'client.post', and then put the file contents as part of the request. This isn't easily supported at the moment because the client requires that the contents be in a string. If your file is large (multiple megabytes) it is an issue and I'm going to address that limitation in the coming 0.9 release. Let me know if you need any more information regarding how to make the file contents part of the POST request. -- Dean Michael Berris deanberris.com |
From: Raindog <ra...@ma...> - 2010-12-03 20:14:07
|
On 12/2/2010 7:24 PM, Dean Michael Berris wrote: > On Fri, Dec 3, 2010 at 11:04 AM, Raindog<ra...@ma...> wrote: > > "Dean Michael Berris"<mik...@gm...> wrote: > >> > >>Actually this isn't an HTTP POST, but rather an HTTP GET request with > >>the query parameter supplied. This would work for what you intend to > >>do: > >> > >> http::client client; > >> http::client::request > >>request("http://www.mysite.com/site.cgi?foo=bar&baz=quid"); > >> http::client::response response = client.get(request); > >> > >>HTH > >> > > > > I realize now that after your response that I need also to send a file, I am trying essentially to fill out a web form w/ a file upload element, along with some options, hence why I thought it was a POST. I apologize for not being clear > > > > Re-arranging your response for posterity. ;) > > So even in that situation, instead of using 'client.get' you can use > 'client.post', and then put the file contents as part of the request. > This isn't easily supported at the moment because the client requires > that the contents be in a string. If your file is large (multiple > megabytes) it is an issue and I'm going to address that limitation in > the coming 0.9 release. > > Let me know if you need any more information regarding how to make the > file contents part of the POST request. > > That would be great if you could. I'm not familiar with HTTP hence why I wanted to use your library =). I know that I need a content length and some field designating the encoding used, but I don't know how I would separate the query string parameters from the actual file being uploaded. Thanks! |
From: Dean M. B. <mik...@gm...> - 2010-12-06 04:34:53
|
On Sat, Dec 4, 2010 at 4:13 AM, Raindog <ra...@ma...> wrote: > On 12/2/2010 7:24 PM, Dean Michael Berris wrote: >> >> Let me know if you need any more information regarding how to make the >> file contents part of the POST request. >> >> > That would be great if you could. I'm not familiar with HTTP hence why I > wanted to use your library =). I know that I need a content length and > some field designating the encoding used, but I don't know how I would > separate the query string parameters from the actual file being uploaded. > That's easy: http::client c; http::client::request req("http://example.com/path?p=0&q=1"); http::client::response res = c.post(req, "The contents of the POST body here."); > Thanks! You're welcome and I hope that helps. -- Dean Michael Berris deanberris.com |
From: Steve O. <st...@so...> - 2010-12-08 06:03:25
|
Hi Dean, I am now back, still jet lagged :) Anyway as I was re-familiarizing myself with the code I noticed that if the user has no network and tries to use the http client they get an exception and the http client quits. I found this out when looking into how to implement the retry on connection failure feature. At this point I have not gone further to root out the cause because a question arose in the process. Should the http client be implemented with all client connections being made under a try/catch block? Or should the http client handle these kind of situations internally? Or is this a bug in the http client. I am using version 0.8 with visual C++ 2010. Regards Steve Obbayi Software Developer http://www.sobbayi.com |
From: Dean M. B. <mik...@gm...> - 2010-12-08 06:21:31
|
Hi Steve, On Wed, Dec 8, 2010 at 2:01 PM, Steve Obbayi <st...@so...> wrote: > Hi Dean, I am now back, still jet lagged :) Great, I hope you had a good vacation. :) > Anyway as I was re-familiarizing myself with the code I noticed that if the user has no > network and tries to use the http client they get an exception and the http client quits. > This is by design -- all operations with the synchronous client (like get, post, put, head, delete_) all throw in case something goes wrong at any stage of the process (except when reading, an eof causes the read from the socket to terminate under normal circumstances). With the asynchronous client, when you try to use any of the wrappers, and there was something wrong in the process of getting the response, it will throw the error that is associated with the error_code received. > I found this out when looking into how to implement the retry on connection failure feature. > > At this point I have not gone further to root out the cause because a question arose in the process. Should the http client be implemented with all client connections being made under a try/catch block? Or should the http client handle these kind of situations internally? Or is this a bug in the http client. > The client is designed to throw when operations are performed, this is so that the user of the client can do what they deem necessary in situations where the client encounters an exceptional condition -- network errors are considered exceptional conditions. ;) > I am using version 0.8 with visual C++ 2010. > You will get this no matter what compiler you use. ;) Also, if you are going to work on anything in cpp-netlib, please work against the latest development branch. Patches submitted against 0.8 will pretty much be useless with the amount of changes that have happened between 0.8 and 0.9-devel. :D HTH -- Dean Michael Berris deanberris.com |
From: Steve O. <st...@so...> - 2010-12-08 15:00:27
|
----- "Dean Michael Berris" <mik...@gm...> wrote: > Hi Steve, > > On Wed, Dec 8, 2010 at 2:01 PM, Steve Obbayi <st...@so...> > wrote: > > Hi Dean, I am now back, still jet lagged :) > > Great, I hope you had a good vacation. :) > > > Anyway as I was re-familiarizing myself with the code I noticed that > if the user has no > > network and tries to use the http client they get an exception and > the http client quits. > > > > This is by design -- all operations with the synchronous client (like > get, post, put, head, delete_) all throw in case something goes wrong > at any stage of the process (except when reading, an eof causes the > read from the socket to terminate under normal circumstances). > > With the asynchronous client, when you try to use any of the wrappers, > and there was something wrong in the process of getting the response, > it will throw the error that is associated with the error_code > received. > > > I found this out when looking into how to implement the retry on > connection failure feature. > > > > At this point I have not gone further to root out the cause because > a question arose in the process. Should the http client be implemented > with all client connections being made under a try/catch block? Or > should the http client handle these kind of situations internally? Or > is this a bug in the http client. > > > > The client is designed to throw when operations are performed, this is > so that the user of the client can do what they deem necessary in > situations where the client encounters an exceptional condition -- > network errors are considered exceptional conditions. ;) > > > I am using version 0.8 with visual C++ 2010. > > > > You will get this no matter what compiler you use. ;) > > Also, if you are going to work on anything in cpp-netlib, please work > against the latest development branch. Patches submitted against 0.8 > will pretty much be useless with the amount of changes that have > happened between 0.8 and 0.9-devel. :D > > HTH > > -- > Dean Michael Berris > deanberris.com > Okay thanks, for confirming this to me. -- Steve Obbayi SKYPE: sobbayi http://sobbayi.com http://blog.sobbayi.com |