| 366 | } |
| 367 | |
| 368 | public String getURL(int port, boolean use_ssl) { |
| 369 | if (version.equals("HTTP/2") || version.equals("HTTP/3")) { |
| 370 | |
| 371 | return getURI(); |
| 372 | } else { /* HTTP/1.1 */ |
| 373 | |
| 374 | String query = (getQueryAsString() != null && getQueryAsString().length() > 0) |
| 375 | ? "?" + getQueryAsString() |
| 376 | : ""; |
| 377 | String path = getPath(); |
| 378 | String host = header.getValue("Host").orElse(null); |
| 379 | String protocol = (use_ssl ? "https" : "http"); |
| 380 | return String.format("%s://%s%s%s", protocol, host, path, query); |
| 381 | } |
| 382 | } |
| 383 | |
| 384 | private String getURI() { |
| 385 | String authority = "unknown"; |