diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-01-10 20:36:00 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-01-10 20:36:00 +0200 |
commit | 7de26af3f47fcd2f409605400bc41b089f54aa44 (patch) | |
tree | d47b6d6af03c50a13b04e6c53d3710448f8120d0 | |
parent | fd7b1c8700761f7af093c145fd5004889e0fbd54 (diff) |
Showing the response header in Page Information
Unsuccessful requests show the response header.
IssueID #97
-rw-r--r-- | src/ui/documentwidget.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 9d284840..b3235755 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -148,6 +148,7 @@ struct Impl_DocumentWidget { | |||
148 | iGmRequest * request; | 148 | iGmRequest * request; |
149 | iAtomicInt isRequestUpdated; /* request has new content, need to parse it */ | 149 | iAtomicInt isRequestUpdated; /* request has new content, need to parse it */ |
150 | iObjectList * media; | 150 | iObjectList * media; |
151 | iString sourceHeader; | ||
151 | iString sourceMime; | 152 | iString sourceMime; |
152 | iBlock sourceContent; /* original content as received, for saving */ | 153 | iBlock sourceContent; /* original content as received, for saving */ |
153 | iTime sourceTime; | 154 | iTime sourceTime; |
@@ -226,6 +227,7 @@ void init_DocumentWidget(iDocumentWidget *d) { | |||
226 | init_Array(&d->outline, sizeof(iOutlineItem)); | 227 | init_Array(&d->outline, sizeof(iOutlineItem)); |
227 | init_Anim(&d->sideOpacity, 0); | 228 | init_Anim(&d->sideOpacity, 0); |
228 | init_Anim(&d->outlineOpacity, 0); | 229 | init_Anim(&d->outlineOpacity, 0); |
230 | init_String(&d->sourceHeader); | ||
229 | init_String(&d->sourceMime); | 231 | init_String(&d->sourceMime); |
230 | init_Block(&d->sourceContent, 0); | 232 | init_Block(&d->sourceContent, 0); |
231 | iZap(d->sourceTime); | 233 | iZap(d->sourceTime); |
@@ -270,6 +272,7 @@ void deinit_DocumentWidget(iDocumentWidget *d) { | |||
270 | deinit_String(&d->pendingGotoHeading); | 272 | deinit_String(&d->pendingGotoHeading); |
271 | deinit_Block(&d->sourceContent); | 273 | deinit_Block(&d->sourceContent); |
272 | deinit_String(&d->sourceMime); | 274 | deinit_String(&d->sourceMime); |
275 | deinit_String(&d->sourceHeader); | ||
273 | iRelease(d->doc); | 276 | iRelease(d->doc); |
274 | if (d->playerTimer) { | 277 | if (d->playerTimer) { |
275 | SDL_RemoveTimer(d->playerTimer); | 278 | SDL_RemoveTimer(d->playerTimer); |
@@ -1013,6 +1016,7 @@ static iBool updateFromHistory_DocumentWidget_(iDocumentWidget *d) { | |||
1013 | /* Use the cached response data. */ | 1016 | /* Use the cached response data. */ |
1014 | updateTrust_DocumentWidget_(d, resp); | 1017 | updateTrust_DocumentWidget_(d, resp); |
1015 | d->sourceTime = resp->when; | 1018 | d->sourceTime = resp->when; |
1019 | format_String(&d->sourceHeader, "(cached content)"); | ||
1016 | updateTimestampBuf_DocumentWidget_(d); | 1020 | updateTimestampBuf_DocumentWidget_(d); |
1017 | set_Block(&d->sourceContent, &resp->body); | 1021 | set_Block(&d->sourceContent, &resp->body); |
1018 | updateDocument_DocumentWidget_(d, resp, iTrue); | 1022 | updateDocument_DocumentWidget_(d, resp, iTrue); |
@@ -1165,6 +1169,7 @@ static void checkResponse_DocumentWidget_(iDocumentWidget *d) { | |||
1165 | d->state = receivedPartialResponse_RequestState; | 1169 | d->state = receivedPartialResponse_RequestState; |
1166 | updateTrust_DocumentWidget_(d, resp); | 1170 | updateTrust_DocumentWidget_(d, resp); |
1167 | init_Anim(&d->sideOpacity, 0); | 1171 | init_Anim(&d->sideOpacity, 0); |
1172 | format_String(&d->sourceHeader, "%d %s", statusCode, get_GmError(statusCode)->title); | ||
1168 | switch (category_GmStatusCode(statusCode)) { | 1173 | switch (category_GmStatusCode(statusCode)) { |
1169 | case categoryInput_GmStatusCode: { | 1174 | case categoryInput_GmStatusCode: { |
1170 | iUrl parts; | 1175 | iUrl parts; |
@@ -1563,7 +1568,15 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd) | |||
1563 | meta = &recent->cachedResponse->meta; | 1568 | meta = &recent->cachedResponse->meta; |
1564 | } | 1569 | } |
1565 | iString *msg = collectNew_String(); | 1570 | iString *msg = collectNew_String(); |
1566 | appendFormat_String(msg, "%s\n%zu bytes\n", cstr_String(meta), size_Block(&d->sourceContent)); | 1571 | if (isEmpty_String(&d->sourceHeader)) { |
1572 | appendFormat_String(msg, "%s\n%zu bytes\n", cstr_String(meta), size_Block(&d->sourceContent)); | ||
1573 | } | ||
1574 | else { | ||
1575 | appendFormat_String(msg, "%s\n", cstr_String(&d->sourceHeader)); | ||
1576 | if (size_Block(&d->sourceContent)) { | ||
1577 | appendFormat_String(msg, "%zu bytes\n", size_Block(&d->sourceContent)); | ||
1578 | } | ||
1579 | } | ||
1567 | appendFormat_String(msg, | 1580 | appendFormat_String(msg, |
1568 | "\n%sCertificate Status:\n%s%s Domain name %s%s\n" | 1581 | "\n%sCertificate Status:\n%s%s Domain name %s%s\n" |
1569 | "%s%s %s (%04d-%02d-%02d %02d:%02d:%02d)\n" | 1582 | "%s%s %s (%04d-%02d-%02d %02d:%02d:%02d)\n" |
@@ -1679,6 +1692,15 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd) | |||
1679 | else if (equalWidget_Command(cmd, w, "document.request.finished") && | 1692 | else if (equalWidget_Command(cmd, w, "document.request.finished") && |
1680 | pointerLabel_Command(cmd, "request") == d->request) { | 1693 | pointerLabel_Command(cmd, "request") == d->request) { |
1681 | set_Block(&d->sourceContent, body_GmRequest(d->request)); | 1694 | set_Block(&d->sourceContent, body_GmRequest(d->request)); |
1695 | if (!isSuccess_GmStatusCode(status_GmRequest(d->request))) { | ||
1696 | format_String(&d->sourceHeader, | ||
1697 | "%d %s", | ||
1698 | status_GmRequest(d->request), | ||
1699 | cstr_String(meta_GmRequest(d->request))); | ||
1700 | } | ||
1701 | else { | ||
1702 | clear_String(&d->sourceHeader); | ||
1703 | } | ||
1682 | updateFetchProgress_DocumentWidget_(d); | 1704 | updateFetchProgress_DocumentWidget_(d); |
1683 | checkResponse_DocumentWidget_(d); | 1705 | checkResponse_DocumentWidget_(d); |
1684 | init_Anim(&d->scrollY, d->initNormScrollY * size_GmDocument(d->doc).y); | 1706 | init_Anim(&d->scrollY, d->initNormScrollY * size_GmDocument(d->doc).y); |