php - Security of this cURL code -


Although "little" relates to the previous question, it is different, in reference to curl, how is this code "safe"? Is there any other "bits" that should be added / added? Note that this is not being used to provide "sensitive" information.

  $ ch = curl_init ("http://www.example.com/test.xml"); Curl_setopt ($ CH, CURLOPT_RETURNTRANSFER, true); Curl_setopt ($ CH, CURLOPT_HEADER, 0); $ Data = curl_xac ($ ch); Curl_close ($ ch);  

Some things to note:

  • If you want to give an error, such as 404 or 500 In that case you may want to take a serious error or present it in your app.
  • You should calculate the amount of data coming on the line what will happen if example.com (or broken in) and test.xml gets several gigabytes of large? The app needs to deal with it, somehow
  • you probably want to include 30x header / redirect logic, curl adherts to a redirect, but in that case, you probably want to Redirection so that you can take action in your app (change location at new location)
  • You should make sure that curl_close () is always called in case of fatal errors, memory overflow and so on, You definitely do not want to open these bases.

Your code is not unsafe, nor is it wrong, it does not handle the side cases and can be harsh.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -