SproutCMS

This is the code documentation for the SproutCMS project

class HttpReq

Simple HTTP(s) request wrapper

Extending this class

<?php
/**
* New class description goes here
* 
* @author Your Name, 2026-09-16
**/
class NewClassName extends HttpReq {
    
    /**
    * Make a simple GET request.
    * If you need more control, use @see HttpReq::req
    **/
    public function get (string $url) {
        // Method code goes here
    }
    
    /**
    * Make a simple POST request, with optional data
    * If you need more control, use @see HttpReq::req
    **/
    public function post (string $url, array $data) {
        // Method code goes here
    }
    
    /**
    * Make a HTTP request. Returns the response content.
    * 
    * The request options array accepts the following keys:
    *   method     The HTTP method to use ('GET', 'POST')
    *   headers    An array of headers; see ::buildHeadersString
    *              for format information
    **/
    public function req (string $url, array $opts, string/array $data) {
        // Method code goes here
    }
    
    /**
    * Sends a HTTP request using fopen (i.e. file_get_contents)
    **/
    private function reqFopen ($url, array $opts, $data) {
        // Method code goes here
    }
    
    /**
    * Sends a HTTP request using cURL.
    **/
    private function reqCurl ($url, array $opts, $data) {
        // Method code goes here
    }
    
    /**
    * Performs a request while permitting advanced cURL options to be specified.
    * Essentially just a wrapper around cURL that has some sane options set by default;
    * e.g. return transfer, no return headers, SSL configured, proxy settings.
    **/
    public function reqAdvanced (string $url, string $method, string|array $post_data, array $curl_options) {
        // Method code goes here
    }
    
    /**
    * Return the http status code ofthe last request
    **/
    public function getLastreqStatus () {
        // Method code goes here
    }
    
    /**
    * Return info of the last request
    **/
    public function getLastreqInfo () {
        // Method code goes here
    }
    
    /**
    * Return headers of the last request
    **/
    public function getLastreqHeaders () {
        // Method code goes here
    }
    
    /**
    * Converts an array of headers into a \r\n-delimeted string
    * 
    * Accepts three formats:
    *  - Strings will be passed through as is.
    *  - Arrays of strings (with numeric keys) will be used as-is
    *  - Arrays of strings (with string keys) will be joined
    *    using : to separate the key and value. Also, values
    *    containing quotes or spaces will be quoted.
    **/
    protected function buildHeadersString (string/array $headers) {
        // Method code goes here
    }
    
}
?>