summaryrefslogtreecommitdiff
path: root/src/gmrequest.h
blob: cb7c151a4032f02b7204571f49ebeeadbd148ca2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#pragma once

#include <the_Foundation/audience.h>
#include <the_Foundation/tlsrequest.h>

#include "gmutil.h"

iDeclareType(GmCerts)
iDeclareType(GmResponse)

enum iGmCertFlags {
    available_GmCertFlag      = iBit(1), /* certificate provided by server */
    trusted_GmCertFlag        = iBit(2), /* TOFU status */
    timeVerified_GmCertFlag   = iBit(3), /* has not expired */
    domainVerified_GmCertFlag = iBit(4), /* cert matches server domain */
};

struct Impl_GmResponse {
    enum iGmStatusCode statusCode;
    iString            meta; /* MIME type or other metadata */
    iBlock             body;
    int                certFlags;
    iDate              certValidUntil;
    iString            certSubject;
};

iDeclareTypeConstruction(GmResponse)
iDeclareTypeSerialization(GmResponse)

iGmResponse *       copy_GmResponse             (const iGmResponse *);

/*----------------------------------------------------------------------------------------------*/

iDeclareClass(GmRequest)
iDeclareObjectConstructionArgs(GmRequest, iGmCerts *)

iDeclareNotifyFunc(GmRequest, Updated)
iDeclareNotifyFunc(GmRequest, Timeout)
iDeclareNotifyFunc(GmRequest, Finished)
iDeclareAudienceGetter(GmRequest, updated)
iDeclareAudienceGetter(GmRequest, timeout)
iDeclareAudienceGetter(GmRequest, finished)

void                setUrl_GmRequest            (iGmRequest *, const iString *url);
void                submit_GmRequest            (iGmRequest *);
void                cancel_GmRequest            (iGmRequest *);

iBool               isFinished_GmRequest        (const iGmRequest *);
enum iGmStatusCode  status_GmRequest            (const iGmRequest *);
const iString *     meta_GmRequest              (const iGmRequest *);
const iBlock  *     body_GmRequest              (const iGmRequest *);
const iString *     url_GmRequest               (const iGmRequest *);
const iGmResponse * response_GmRequest          (const iGmRequest *);

int                 certFlags_GmRequest         (const iGmRequest *);
iDate               certExpirationDate_GmRequest(const iGmRequest *);