/**
 * File:    modules/HTTP.ycp
 * Package: Transfer Protocols
 * Summary: Handle HTTP Requests
 * Authors: Anas Nashif <nashif@suse.de>
 *
 * $Id: HTTP.ycp,v 1.6 2003/11/25 11:40:32 msvec Exp $
 */

{

module "HTTP";

global string user = "";
global string password = "";

/**
 * Send a get request
 * @param url url in any standard form
 * @param output file to save result to
 * @return map Reponse map with HTTP code and transfer size and time
 */
global define map Get(string url, string output) ``{
    y2debug("URL: %1", url);
    map response = (map) SCR::Execute(.curl.get, url, $["output":output]);
    return response;
}

/**
 * Send a post request
 * @param url url in any standard form
 * @param output file to save result to
 * @param postdata the rest of the url and whatever comes after the ? in the URL
 * @return map Reponse map with HTTP code and transfer size and time
 */

global define map Post(string url, string output, string postData) ``{
    y2debug("URL: %1", url);
    map response = (map) SCR::Execute(.curl.get, url, $["output":output, "data":postData]);
    return response;
}


/**
 * Set user and password for HTTP authentication
 */


global define map setUserPassword() ``{
    string userpass = sformat("%1:%2", user , password );
    return (map) SCR::Execute(.curl.setUserPassword, userpass, $[]);
}

/* EOF */
}
