|  | 
  John Yiangos - 2005-05-10 06:02:07Hello,
 I've been using this class for quite a while, and I noticed something very weird: it seems that the class stops functioning after a while (a month or so). In particular, the SendRequest() method stops working (it hangs). I browsed through the code, but didn't find anything to tell me why this is happening. The server log (apache 2.0.46 on FC 2) doesn't help either, no reports there.
 
 By the way, nice work. It's the only http client out there (as far as I know) that can post to a secure server (https) and send a page with a body, not just headers. The only thing that needs a bit of improvement is the documentation (in my opinion :))
 
 Regards,
 Yiannis Vavouranakis
  Manuel Lemos - 2005-05-10 16:57:10 - In reply to message 1 from John YiangosWithout more information it is hard to tell what is the problem.
 It would be good if you could send me an example script that exhibits the problem.
 
 If you can enable debug support, it would be useful to see the output until it hangs.
 
 It would also be interesting to know the PHP version and OS that you use.
 
 
 As for the documentation, that is in my plans but I need to find more free time to do it.
  John Yiangos - 2005-05-11 06:34:26 - In reply to message 2 from Manuel LemosActually, I think I found what the problem is, but I haven't found a way to work around it. Here's the case:
 I'm supposed to send a request to a server via POST. However, there should not be any CURLOPT_POSTFIELDS, but he body of the request, on the other hand, needs to be a dynamically created xml document (not in a file to upload, just the body). The server uses secure connections (https) so fsockopen() that most other http client classes use, is out of the question.
 
 In the class, you incorporate the entire request (headers and body) in a single string and use it as the value for CURLOPT_CUSTOMREQUEST. This is where things get sticky, as the remote server does not recognize that string as a request method. So what happens is that my server just lets the script go on aond on (I had neglected to set the CURLOPT_TIMEOUT option. As soon as I tried the same request through plain CURL/PHP functions I saw the trouble).
 
 Now the trouble is I can't seem to find a CURLOPT in php.net for adding a body in the request. Maybe it's CURLOPT_READFUNCTION, but the documentation on that is so scarce (even among the user notes) that I am beginning to give up on the idea :(.
 
 Any input is invaluable.
 
 Regards,
 Yiannis Vavouranakis
  Manuel Lemos - 2005-05-11 13:40:47 - In reply to message 3 from John YiangosIf you are using the CURL library directly, I cannot help you. This class only uses the CURL library when you need to access an SSL server and the OpenSSL extension is not available.
 When this class uses the CURL library it builds a custom request because the CURL library form of composing requests is not flexible enough.
 
 To send a POST request with an arbitrary request body, you can use the "Body" request argument as demonstrated in the test_http_soap.php example.
  John Yiangos - 2005-05-11 22:10:32 - In reply to message 4 from Manuel LemosWell, actually, I mentioned the CURL functions just because you use the "body" argument in that particular way. What I'm saying is that the way the "body" argument is sent is not accepted by the remote server. When the remote server receives whatever CURL sends off as CUSTOMREQUEST, it expects to see something like "HEAD", "POST", GET", "PUT", etc. not the whole request (full headers and body). 
 Anyway, I found a quick solution to my problem, only without PHP - python has a nice HTTP Client library preinstalled.
 
 However, I still think your class is one of the best (if not the best) pure PHP HTTP Clients I've seen around.
 
 Regards,
 Yiannis Vavouranakis
  Manuel Lemos - 2005-05-12 03:49:02 - In reply to message 5 from John YiangosWhat I am trying to tell you is that it is unlikely that the class is using CURL library despite the code for using CURL is there.
 As I mentioned before, the class only tries to use the CURL library when you want to send SSL requests and your PHP version is older than 4.3.0 or you have not OpenSSL extension installed.
 
 So, even if it is correct to assume that the problem is in the way the class uses the CURL library, if you really want to send requests over SSL, you could simply have enabled the OpenSSL extension, and so it would no longer use CURL. Therefore I am surprised that you determined that using Python would be a better solution.
 
 Anyway, what I find most frustrating in this matter, is that you have not helped me to reproduce the problem as I requested. Therefore, if there is really a problem with the class, I have no way to fix it because I don't know how to reproduce it.
 
 This defeats my original motivation to release my work as Open Source, which is to receive helpful feedback to let me fix and improve the class features.
  John Yiangos - 2005-05-12 15:44:55 - In reply to message 6 from Manuel LemosI said "quick" not "Better" :-)
 Using python opened up a host of other problems, which are irrelevant to this thread.
 
 Anyway, I read your solution, but I really can't give you the example, as what I'm trying to do involves sending out a username and a password, and I can't give those away - hopefully you understand what I mean.
 
 I'll _try_ to activate OpenSSL, but I'm not sure I can do that, I didn't build PHP from sources (actually, I didn't build it myself at all, someone else is responsible for the maintenance of the server).
 
 I'll let you know how things go, and try to find a way to give you access to what I'm doing.
 
 Regards,
 Yiannis Vavouranakis
  Manuel Lemos - 2005-05-12 16:29:11 - In reply to message 7 from John YiangosI understand. The problem that you described may be cause by wrong content length header. Since you mentioned you use authentication, it may also be related. Still, without seeing what exactly is sent back and forth to the server, I can hardly do anything.
 Maybe if you can create a temporary account that I can use to reproduce the problem, I can do what it takes to solve it and then you can remove the account later. Just mail me privately in case that it is possible.
  Manuel Lemos - 2005-05-14 04:20:18 - In reply to message 8 from Manuel LemosI just realized that your problem could be due to bug in curl library versions older than 7.13.2 that prevented it to handle 100 Continue responses of HTTP 1.1 servers.
 I just uploaded a new version of the class with a workaround that forces submitting HTTP 1.0 requests when the installed curl library version is old. Please try it and let me know if that solves your problem.
  John Yiangos - 2005-05-15 16:33:46 - In reply to message 9 from Manuel LemosThanks , I'll try it and let you know
 Regards,
 Yiannis Vavouranakis
 |