Back to index

nordugrid-arc-nox  1.1.0~rc6
Public Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes
Arc::ClientHTTP Class Reference

Class for setting up a MCC chain for HTTP communication. More...

#include <ClientInterface.h>

Inheritance diagram for Arc::ClientHTTP:
Inheritance graph
[legend]
Collaboration diagram for Arc::ClientHTTP:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ClientHTTP ()
 ClientHTTP (const BaseConfig &cfg, const URL &url, int timeout=-1, const std::string &proxy_host="", int proxy_port=0)
virtual ~ClientHTTP ()
MCC_Status process (const std::string &method, PayloadRawInterface *request, HTTPClientInfo *info, PayloadRawInterface **response)
MCC_Status process (const std::string &method, std::multimap< std::string, std::string > &attributes, PayloadRawInterface *request, HTTPClientInfo *info, PayloadRawInterface **response)
MCC_Status process (const std::string &method, const std::string &path, PayloadRawInterface *request, HTTPClientInfo *info, PayloadRawInterface **response)
MCC_Status process (const std::string &method, const std::string &path, std::multimap< std::string, std::string > &attributes, PayloadRawInterface *request, HTTPClientInfo *info, PayloadRawInterface **response)
MCC_Status process (const std::string &method, const std::string &path, uint64_t range_start, uint64_t range_end, PayloadRawInterface *request, HTTPClientInfo *info, PayloadRawInterface **response)
MCC_Status process (const std::string &method, const std::string &path, std::multimap< std::string, std::string > &attributes, uint64_t range_start, uint64_t range_end, PayloadRawInterface *request, HTTPClientInfo *info, PayloadRawInterface **response)
MCCGetEntry ()
void AddSecHandler (XMLNode handlercfg, const std::string &libanme="", const std::string &libpath="")
virtual bool Load ()
void RelativeURI (bool val)
MCC_Status process (PayloadRawInterface *request, PayloadStreamInterface **response, bool tls)
void AddSecHandler (XMLNode handlercfg, SecurityLayer sec, const std::string &libanme="", const std::string &libpath="")
void Overlay (XMLNode cfg)
const ConfigGetConfig () const
MessageContextGetContext ()

Static Protected Member Functions

static void AddSecHandler (XMLNode mcccfg, XMLNode handlercfg)
static void AddPlugin (XMLNode mcccfg, const std::string &libname, const std::string &libpath="")

Protected Attributes

MCChttp_entry
URL default_url
bool relative_uri
SecurityLayer sec
MCCtcp_entry
MCCtls_entry
Config xmlcfg
XMLNode overlay
MCCLoaderloader
MessageContext context

Static Protected Attributes

static Logger logger

Detailed Description

Class for setting up a MCC chain for HTTP communication.

The ClientHTTP class inherits from the ClientTCP class and adds an HTTP MCC to the chain.

Definition at line 101 of file ClientInterface.h.


Constructor & Destructor Documentation

Definition at line 104 of file ClientInterface.h.

      : http_entry(NULL) {}
Arc::ClientHTTP::ClientHTTP ( const BaseConfig cfg,
const URL url,
int  timeout = -1,
const std::string &  proxy_host = "",
int  proxy_port = 0 
)

Definition at line 276 of file ClientInterface.cpp.

    : ClientTCP(cfg,
                get_http_proxy_host(url,proxy_host,proxy_port),
                get_http_proxy_port(url,proxy_host,proxy_port),
                url.Protocol() == "https" ? TLSSec
                  : url.Protocol() == "httpg" ? GSISec
                    : NoSec,
                timeout,
                url.Option("tcpnodelay") == "yes"),
      http_entry(NULL),
      default_url(url),
      relative_uri(false),
      sec(url.Protocol() == "https" ? TLSSec
            : url.Protocol() == "httpg" ? GSISec
                : NoSec) {
    XMLNode comp = ConfigMakeComponent(xmlcfg["Chain"], "http.client", "http",
                                       sec == TLSSec ? "tls" :
                                       sec == GSISec ? "gsi" : "tcp");
    comp.NewAttribute("entry") = "http";
    comp.NewChild("Method") = "POST"; // Override using attributes if needed
    comp.NewChild("Endpoint") = url.str();
  }

Here is the call graph for this function:

Definition at line 299 of file ClientInterface.cpp.

{}

Member Function Documentation

void Arc::ClientInterface::AddPlugin ( XMLNode  mcccfg,
const std::string &  libname,
const std::string &  libpath = "" 
) [static, protected, inherited]

Definition at line 107 of file ClientInterface.cpp.

                                                                                                    {
    if (!libpath.empty()) {
      XMLNode mm = mcccfg["ModuleManager"];
      if (!mm)
        mcccfg.NewChild("ModuleManager", 0);
      XMLNode mp = mm["Path"];
      for (; (bool)mp; ++mp)
        if (mp == libpath)
          break;
      if (!mp)
        mm.NewChild("Path") = libpath;
    }
    if (!libname.empty()) {
      XMLNode pl = mcccfg["Plugins"];
      for (; (bool)pl; ++pl)
        if (pl["Name"] == libname)
          break;
      if (!pl)
        mcccfg.NewChild("Plugins", 0).NewChild("Name") = libname;
    }
  }

Here is the call graph for this function:

Here is the caller graph for this function:

void Arc::ClientInterface::AddSecHandler ( XMLNode  mcccfg,
XMLNode  handlercfg 
) [static, protected, inherited]

Definition at line 101 of file ClientInterface.cpp.

                                                                        {
    // Insert SecHandler configuration into MCC configuration block
    // Make sure namespaces and names are correct
    mcccfg.NewChild(handlercfg).Name("SecHandler");
  }

Here is the call graph for this function:

void Arc::ClientTCP::AddSecHandler ( XMLNode  handlercfg,
SecurityLayer  sec,
const std::string &  libanme = "",
const std::string &  libpath = "" 
) [inherited]

Definition at line 223 of file ClientInterface.cpp.

                                                                                                                         {
    if (sec == TLSSec)
      ClientInterface::AddSecHandler(
        ConfigFindComponent(xmlcfg["Chain"], "tls.client", "tls"),
        handlercfg);
    else if (sec == GSISec)
      ClientInterface::AddSecHandler(
        ConfigFindComponent(xmlcfg["Chain"], "gsi.client", "gsi"),
        handlercfg);
    else
      ClientInterface::AddSecHandler(
        ConfigFindComponent(xmlcfg["Chain"], "tcp.client", "tcp"),
        handlercfg);
    for (XMLNode pl = handlercfg["Plugins"]; (bool)pl; ++pl)
      AddPlugin(xmlcfg, pl["Name"]);
    AddPlugin(xmlcfg, libname, libpath);
  }

Here is the call graph for this function:

void Arc::ClientHTTP::AddSecHandler ( XMLNode  handlercfg,
const std::string &  libanme = "",
const std::string &  libpath = "" 
)

Reimplemented in Arc::ClientSOAP.

Definition at line 432 of file ClientInterface.cpp.

                                                                                                       {
    ClientInterface::AddSecHandler(
      ConfigFindComponent(xmlcfg["Chain"], "http.client", "http"),
      handlercfg);
    for (XMLNode pl = handlercfg["Plugins"]; (bool)pl; ++pl)
      AddPlugin(xmlcfg, pl["Name"]);
    AddPlugin(xmlcfg, libname, libpath);
  }

Here is the call graph for this function:

const Config& Arc::ClientInterface::GetConfig ( ) const [inline, inherited]

Definition at line 39 of file ClientInterface.h.

                                    {
      return xmlcfg;
    }

Here is the caller graph for this function:

Definition at line 42 of file ClientInterface.h.

                                 {
      return context;
    }

Here is the caller graph for this function:

Reimplemented from Arc::ClientTCP.

Reimplemented in Arc::ClientSOAP.

Definition at line 130 of file ClientInterface.h.

                    {
      return http_entry;
    }
bool Arc::ClientHTTP::Load ( ) [virtual]

Reimplemented from Arc::ClientTCP.

Reimplemented in Arc::ClientSOAP.

Definition at line 301 of file ClientInterface.cpp.

                        {
    if(!ClientTCP::Load()) return false;
    if (!http_entry)
      http_entry = (*loader)["http"];
    if (!http_entry) return false;
    return true;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

void Arc::ClientInterface::Overlay ( XMLNode  cfg) [inherited]

Definition at line 97 of file ClientInterface.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

MCC_Status Arc::ClientTCP::process ( PayloadRawInterface request,
PayloadStreamInterface **  response,
bool  tls 
) [inherited]

Definition at line 188 of file ClientInterface.cpp.

                                                                             {
    *response = NULL;
    if (!Load())
      return MCC_Status();
    if (tls && !tls_entry)
      return MCC_Status();
    if (!tls && !tcp_entry)
      return MCC_Status();
    MessageAttributes attributes_req;
    MessageAttributes attributes_rep;
    Message reqmsg;
    Message repmsg;
    reqmsg.Attributes(&attributes_req);
    reqmsg.Context(&context);
    reqmsg.Payload(request);
    repmsg.Attributes(&attributes_rep);
    repmsg.Context(&context);

    MCC_Status r;
    if (tls)
      r = tls_entry->process(reqmsg, repmsg);
    else
      r = tcp_entry->process(reqmsg, repmsg);

    if (repmsg.Payload() != NULL)
      try {
        *response =
          dynamic_cast<PayloadStreamInterface*>(repmsg.Payload());
      } catch (std::exception&) {
        delete repmsg.Payload();
      }
    return r;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

MCC_Status Arc::ClientHTTP::process ( const std::string &  method,
PayloadRawInterface request,
HTTPClientInfo info,
PayloadRawInterface **  response 
)

Definition at line 309 of file ClientInterface.cpp.

                                                                 {
    std::multimap<std::string, std::string> attributes;
    return process(method, "", attributes, 0, UINT64_MAX, request, info, response);
  }

Here is the caller graph for this function:

MCC_Status Arc::ClientHTTP::process ( const std::string &  method,
std::multimap< std::string, std::string > &  attributes,
PayloadRawInterface request,
HTTPClientInfo info,
PayloadRawInterface **  response 
)

Definition at line 317 of file ClientInterface.cpp.

                                                         {
    return process(method, "", attributes, 0, UINT64_MAX, request, info, response);
  }

Here is the call graph for this function:

MCC_Status Arc::ClientHTTP::process ( const std::string &  method,
const std::string &  path,
PayloadRawInterface request,
HTTPClientInfo info,
PayloadRawInterface **  response 
)

Definition at line 325 of file ClientInterface.cpp.

                                                                 {
    std::multimap<std::string, std::string> attributes;
    return process(method, path, attributes, 0, UINT64_MAX, request, info, response);
  }

Here is the call graph for this function:

MCC_Status Arc::ClientHTTP::process ( const std::string &  method,
const std::string &  path,
std::multimap< std::string, std::string > &  attributes,
PayloadRawInterface request,
HTTPClientInfo info,
PayloadRawInterface **  response 
)

Definition at line 334 of file ClientInterface.cpp.

                                                         {
    return process(method, path, attributes, 0, UINT64_MAX, request, info, response);
  }

Here is the call graph for this function:

MCC_Status Arc::ClientHTTP::process ( const std::string &  method,
const std::string &  path,
uint64_t  range_start,
uint64_t  range_end,
PayloadRawInterface request,
HTTPClientInfo info,
PayloadRawInterface **  response 
)

Definition at line 343 of file ClientInterface.cpp.

                                                                 {
    std::multimap<std::string, std::string> attributes;
    return process(method, path, attributes, range_start, range_end, request, info, response);
  }

Here is the call graph for this function:

MCC_Status Arc::ClientHTTP::process ( const std::string &  method,
const std::string &  path,
std::multimap< std::string, std::string > &  attributes,
uint64_t  range_start,
uint64_t  range_end,
PayloadRawInterface request,
HTTPClientInfo info,
PayloadRawInterface **  response 
)

Definition at line 353 of file ClientInterface.cpp.

                                                         {
    *response = NULL;
    if (!Load())
      return MCC_Status();
    if (!http_entry)
      return MCC_Status();
    MessageAttributes attributes_req;
    MessageAttributes attributes_rep;
    Message reqmsg;
    Message repmsg;
    reqmsg.Attributes(&attributes_req);
    reqmsg.Context(&context);
    reqmsg.Payload(request);
    repmsg.Attributes(&attributes_rep);
    repmsg.Context(&context);
    reqmsg.Attributes()->set("HTTP:METHOD", method);
    if (!path.empty()) {
      URL url(default_url);
      url.ChangePath(path);
      if(relative_uri) {
        // Workaround for servers which can't handle full URLs in request
        reqmsg.Attributes()->set("HTTP:HOST", url.Host() + ":" + tostring(url.Port()));
        std::string rpath = url.FullPath();
        if(rpath[0] != '/') rpath.insert(0,"/");
        reqmsg.Attributes()->set("HTTP:ENDPOINT", rpath);
      } else {
        reqmsg.Attributes()->set("HTTP:ENDPOINT", url.str());
      }
    } else {
      if(relative_uri) {
        reqmsg.Attributes()->set("HTTP:HOST", default_url.Host() + ":" + tostring(default_url.Port()));
        std::string rpath = default_url.FullPath();
        if(rpath[0] != '/') rpath.insert(0,"/");
        reqmsg.Attributes()->set("HTTP:ENDPOINT", rpath);
      }
    }
    if (range_end != UINT64_MAX)
      reqmsg.Attributes()->set("HTTP:Range", "bytes=" + tostring(range_start) +
                               "-" + tostring(range_end));
    else if (range_start != 0)
      reqmsg.Attributes()->set("HTTP:Range", "bytes=" +
                               tostring(range_start) + "-");
    std::map<std::string, std::string>::iterator it;
    for (it = attributes.begin(); it != attributes.end(); it++) {
      std::string key("HTTP:");
      key.append((*it).first);
      reqmsg.Attributes()->add(key, (*it).second);
    }
    MCC_Status r = http_entry->process(reqmsg, repmsg);
    if(!r) {
      if (repmsg.Payload() != NULL) delete repmsg.Payload();
      return r;
    };
    stringto(repmsg.Attributes()->get("HTTP:CODE"),info->code);
    info->reason = repmsg.Attributes()->get("HTTP:REASON");
    stringto(repmsg.Attributes()->get("HTTP:content-length"),info->size);
    std::string lm;
    lm = repmsg.Attributes()->get("HTTP:last-modified");
    if (lm.size() > 11)
      info->lastModified = lm;
    info->type = repmsg.Attributes()->get("HTTP:content-type");
    for(AttributeIterator i = repmsg.Attributes()->getAll("HTTP:set-cookie");
        i.hasMore();++i) info->cookies.push_back(*i);
    info->location = repmsg.Attributes()->get("HTTP:location");
    if (repmsg.Payload() != NULL)
      try {
        *response = dynamic_cast<PayloadRawInterface*>(repmsg.Payload());
      } catch (std::exception&) {
        delete repmsg.Payload();
      }
    return r;
  }

Here is the call graph for this function:

void Arc::ClientHTTP::RelativeURI ( bool  val) [inline]

Definition at line 135 of file ClientInterface.h.

{ relative_uri=val; };

Member Data Documentation

Definition at line 50 of file ClientInterface.h.

Definition at line 138 of file ClientInterface.h.

Definition at line 135 of file ClientInterface.h.

MCCLoader* Arc::ClientInterface::loader [protected, inherited]

Definition at line 49 of file ClientInterface.h.

Logger Arc::ClientInterface::logger [static, protected, inherited]

Definition at line 51 of file ClientInterface.h.

XMLNode Arc::ClientInterface::overlay [protected, inherited]

Definition at line 48 of file ClientInterface.h.

Definition at line 139 of file ClientInterface.h.

Definition at line 140 of file ClientInterface.h.

MCC* Arc::ClientTCP::tcp_entry [protected, inherited]

Definition at line 83 of file ClientInterface.h.

MCC* Arc::ClientTCP::tls_entry [protected, inherited]

Definition at line 84 of file ClientInterface.h.

Config Arc::ClientInterface::xmlcfg [protected, inherited]

Definition at line 47 of file ClientInterface.h.


The documentation for this class was generated from the following files: