MCPcopy Create free account
hub / github.com/acl-dev/acl / getRemotePort

Method getRemotePort

lib_acl_cpp/src/http/HttpServletRequest.cpp:441–469  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

439}
440
441unsigned short HttpServletRequest::getRemotePort(void) const
442{
443 if (cgi_mode_) {
444 const char* ptr = acl_getenv("REMOTE_PORT");
445 if (ptr && *ptr) {
446 return atoi(ptr);
447 }
448 logger_warn("no REMOTE_PORT from acl_getenv");
449 return 0;
450 }
451 if (client_ == NULL) {
452 return 0;
453 }
454 const char* ptr = client_->get_stream().get_peer(true);
455 if (*ptr == 0) {
456 logger_warn("get_peer return empty string");
457 return 0;
458 }
459 char* port = (char*) strchr(ptr, '|');
460 if (port == NULL) {
461 port = (char*) strchr(ptr, ':');
462 }
463 if (port == NULL || *(++port) == 0) {
464 logger_warn("no port in addr: %s", ptr);
465 return 0;
466 }
467
468 return atoi(port);
469}
470
471const char* HttpServletRequest::getParameter(const char* name,
472 bool case_sensitive /* = false */) const

Callers

nothing calls this directly

Calls 3

acl_getenvFunction · 0.85
get_peerMethod · 0.45
get_streamMethod · 0.45

Tested by

no test coverage detected