PACS System 0.1.0
PACS DICOM system library
Loading...
Searching...
No Matches
parsed_url Struct Reference

Parse URL into host, port, and path components. More...

Collaboration diagram for parsed_url:
Collaboration graph

Static Public Member Functions

static std::optional< parsed_urlparse (const std::string &url)
 

Public Attributes

std::string host
 
std::string port
 
std::string path
 

Detailed Description

Parse URL into host, port, and path components.

Definition at line 511 of file ai_service_connector.cpp.

Member Function Documentation

◆ parse()

static std::optional< parsed_url > parsed_url::parse ( const std::string & url)
inlinestatic

Definition at line 516 of file ai_service_connector.cpp.

516 {
517 parsed_url result;
518
519 // Find scheme end
520 auto scheme_end = url.find("://");
521 if (scheme_end == std::string::npos) return std::nullopt;
522
523 auto host_start = scheme_end + 3;
524 auto path_start = url.find('/', host_start);
525
526 std::string host_port;
527 if (path_start == std::string::npos) {
528 host_port = url.substr(host_start);
529 result.path = "/";
530 } else {
531 host_port = url.substr(host_start, path_start - host_start);
532 result.path = url.substr(path_start);
533 }
534
535 auto colon = host_port.find(':');
536 if (colon != std::string::npos) {
537 result.host = host_port.substr(0, colon);
538 result.port = host_port.substr(colon + 1);
539 } else {
540 result.host = host_port;
541 result.port = "80";
542 }
543
544 return result;
545 }
Parse URL into host, port, and path components.

References host, path, and port.

Referenced by http_client::send_request().

Here is the caller graph for this function:

Member Data Documentation

◆ host

std::string parsed_url::host

Definition at line 512 of file ai_service_connector.cpp.

Referenced by parse().

◆ path

std::string parsed_url::path

Definition at line 514 of file ai_service_connector.cpp.

Referenced by parse().

◆ port

std::string parsed_url::port

Definition at line 513 of file ai_service_connector.cpp.

Referenced by parse().


The documentation for this struct was generated from the following file: