summaryrefslogtreecommitdiff
path: root/src/gmrequest.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-09-14 19:55:20 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-09-14 19:55:20 +0300
commit5119a72481a2c752972470ea7b488a5c9e58b720 (patch)
tree11c7ed98a7ba49b300b07585ad497720d8feb4ed /src/gmrequest.c
parentf68cc75e67cc7504622d55d473c192977957f346 (diff)
UploadWidget: Identity selection (mobile)
Diffstat (limited to 'src/gmrequest.c')
-rw-r--r--src/gmrequest.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/gmrequest.c b/src/gmrequest.c
index 00a02983..1a9e83a9 100644
--- a/src/gmrequest.c
+++ b/src/gmrequest.c
@@ -158,6 +158,7 @@ struct Impl_GmRequest {
158 uint32_t id; 158 uint32_t id;
159 iMutex * mtx; 159 iMutex * mtx;
160 iGmCerts * certs; /* not owned */ 160 iGmCerts * certs; /* not owned */
161 const iGmIdentity * identity;
161 enum iGmRequestState state; 162 enum iGmRequestState state;
162 iString url; 163 iString url;
163 iTitanData * titan; 164 iTitanData * titan;
@@ -527,6 +528,7 @@ static void beginGopherConnection_GmRequest_(iGmRequest *d, const iString *host,
527void init_GmRequest(iGmRequest *d, iGmCerts *certs) { 528void init_GmRequest(iGmRequest *d, iGmCerts *certs) {
528 d->mtx = new_Mutex(); 529 d->mtx = new_Mutex();
529 d->id = add_Atomic(&idGen_, 1) + 1; 530 d->id = add_Atomic(&idGen_, 1) + 1;
531 d->identity = NULL;
530 d->resp = new_GmResponse(); 532 d->resp = new_GmResponse();
531 d->isFilterEnabled = iTrue; 533 d->isFilterEnabled = iTrue;
532 d->isRespLocked = iFalse; 534 d->isRespLocked = iFalse;
@@ -582,6 +584,11 @@ void setUrl_GmRequest(iGmRequest *d, const iString *url) {
582 the web. */ 584 the web. */
583 urlEncodePath_String(&d->url); 585 urlEncodePath_String(&d->url);
584 urlEncodeSpaces_String(&d->url); 586 urlEncodeSpaces_String(&d->url);
587 d->identity = identityForUrl_GmCerts(d->certs, &d->url);
588}
589
590void setIdentity_GmRequest(iGmRequest *d, const iGmIdentity *id) {
591 d->identity = id;
585} 592}
586 593
587static iBool isTitan_GmRequest_(const iGmRequest *d) { 594static iBool isTitan_GmRequest_(const iGmRequest *d) {
@@ -902,9 +909,8 @@ void submit_GmRequest(iGmRequest *d) {
902 } 909 }
903 d->state = receivingHeader_GmRequestState; 910 d->state = receivingHeader_GmRequestState;
904 d->req = new_TlsRequest(); 911 d->req = new_TlsRequest();
905 const iGmIdentity *identity = identityForUrl_GmCerts(d->certs, &d->url); 912 if (d->identity) {
906 if (identity) { 913 setCertificate_TlsRequest(d->req, d->identity->cert);
907 setCertificate_TlsRequest(d->req, identity->cert);
908 } 914 }
909 iConnect(TlsRequest, d->req, readyRead, d, readIncoming_GmRequest_); 915 iConnect(TlsRequest, d->req, readyRead, d, readIncoming_GmRequest_);
910 iConnect(TlsRequest, d->req, sent, d, bytesSent_GmRequest_); 916 iConnect(TlsRequest, d->req, sent, d, bytesSent_GmRequest_);