diff options
Diffstat (limited to 'src/gmrequest.c')
-rw-r--r-- | src/gmrequest.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/gmrequest.c b/src/gmrequest.c index 391c7e89..24732650 100644 --- a/src/gmrequest.c +++ b/src/gmrequest.c | |||
@@ -402,6 +402,9 @@ void submit_GmRequest(iGmRequest *d) { | |||
402 | init_Url(&url, &d->url); | 402 | init_Url(&url, &d->url); |
403 | /* Check for special schemes. */ | 403 | /* Check for special schemes. */ |
404 | /* TODO: If this were a library, these could be handled via callbacks. */ | 404 | /* TODO: If this were a library, these could be handled via callbacks. */ |
405 | /* TODO: Handle app's configured proxies and these via the same mechanism. */ | ||
406 | const iString *host = collect_String(newRange_String(url.host)); | ||
407 | uint16_t port = toInt_String(collect_String(newRange_String(url.port))); | ||
405 | if (equalCase_Rangecc(url.scheme, "about")) { | 408 | if (equalCase_Rangecc(url.scheme, "about")) { |
406 | const iBlock *src = aboutPageSource_(url.path); | 409 | const iBlock *src = aboutPageSource_(url.path); |
407 | if (src) { | 410 | if (src) { |
@@ -487,6 +490,19 @@ void submit_GmRequest(iGmRequest *d) { | |||
487 | iNotifyAudience(d, finished, GmRequestFinished); | 490 | iNotifyAudience(d, finished, GmRequestFinished); |
488 | return; | 491 | return; |
489 | } | 492 | } |
493 | else if (schemeProxy_App(url.scheme)) { | ||
494 | /* User has configured a proxy server for this scheme. */ | ||
495 | const iString *proxy = schemeProxy_App(url.scheme); | ||
496 | if (contains_String(proxy, ':')) { | ||
497 | const size_t cpos = indexOf_String(proxy, ':'); | ||
498 | port = atoi(cstr_String(proxy) + cpos + 1); | ||
499 | host = collect_String(newCStrN_String(cstr_String(proxy), cpos)); | ||
500 | } | ||
501 | else { | ||
502 | host = proxy; | ||
503 | port = 0; | ||
504 | } | ||
505 | } | ||
490 | d->state = receivingHeader_GmRequestState; | 506 | d->state = receivingHeader_GmRequestState; |
491 | d->req = new_TlsRequest(); | 507 | d->req = new_TlsRequest(); |
492 | const iGmIdentity *identity = identityForUrl_GmCerts(d->certs, &d->url); | 508 | const iGmIdentity *identity = identityForUrl_GmCerts(d->certs, &d->url); |
@@ -495,11 +511,10 @@ void submit_GmRequest(iGmRequest *d) { | |||
495 | } | 511 | } |
496 | iConnect(TlsRequest, d->req, readyRead, d, readIncoming_GmRequest_); | 512 | iConnect(TlsRequest, d->req, readyRead, d, readIncoming_GmRequest_); |
497 | iConnect(TlsRequest, d->req, finished, d, requestFinished_GmRequest_); | 513 | iConnect(TlsRequest, d->req, finished, d, requestFinished_GmRequest_); |
498 | uint16_t port = toInt_String(collect_String(newRange_String(url.port))); | ||
499 | if (port == 0) { | 514 | if (port == 0) { |
500 | port = 1965; /* default Gemini port */ | 515 | port = 1965; /* default Gemini port */ |
501 | } | 516 | } |
502 | setUrl_TlsRequest(d->req, collect_String(newRange_String(url.host)), port); | 517 | setUrl_TlsRequest(d->req, host, port); |
503 | setContent_TlsRequest(d->req, | 518 | setContent_TlsRequest(d->req, |
504 | utf8_String(collectNewFormat_String("%s\r\n", cstr_String(&d->url)))); | 519 | utf8_String(collectNewFormat_String("%s\r\n", cstr_String(&d->url)))); |
505 | submit_TlsRequest(d->req); | 520 | submit_TlsRequest(d->req); |