HTMLv: support for HTTP redirects (3xx).
git-svn-id: svn://kolibrios.org@4558 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
9297b1d4c8
commit
90fa4be334
@ -50,6 +50,8 @@ proc_info Form;
|
|||||||
#define WIN_H 480
|
#define WIN_H 480
|
||||||
|
|
||||||
char search_path[]="http://nigma.ru/index.php?s=";
|
char search_path[]="http://nigma.ru/index.php?s=";
|
||||||
|
char str_location[]="location\0";
|
||||||
|
int redirected = 0;
|
||||||
|
|
||||||
char stak[4096];
|
char stak[4096];
|
||||||
mouse m;
|
mouse m;
|
||||||
@ -183,15 +185,37 @@ void main()
|
|||||||
|
|
||||||
$pop EAX
|
$pop EAX
|
||||||
if (EAX == 0) {
|
if (EAX == 0) {
|
||||||
|
ESI = http_transfer;
|
||||||
|
// Handle redirects
|
||||||
|
if (ESI.http_msg.status >= 300) && (ESI.http_msg.status < 400) {
|
||||||
|
redirected++;
|
||||||
|
if (redirected<=5) {
|
||||||
|
http_find_header_field stdcall (http_transfer, #str_location);
|
||||||
|
if (EAX!=0) {
|
||||||
|
ESI = EAX;
|
||||||
|
EDI = #URL;
|
||||||
|
do {
|
||||||
|
$lodsb;
|
||||||
|
$stosb;
|
||||||
|
} while (AL != 0) && (AL != 13) && (AL != 10));
|
||||||
|
DSBYTE[EDI-1]='\0';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//TODO: display error (too many redirects)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
redirected = 0;
|
||||||
|
}
|
||||||
// Loading the page is complete, free resources
|
// Loading the page is complete, free resources
|
||||||
http_free stdcall (http_transfer);
|
http_free stdcall (http_transfer);
|
||||||
http_transfer=0;
|
http_transfer=0;
|
||||||
Draw_Window(); // stop button => refresh button
|
if (redirected>0) {
|
||||||
|
WB1.GetNewUrl();
|
||||||
|
strcpy(#editURL, #URL);
|
||||||
|
OpenPage();
|
||||||
} else {
|
} else {
|
||||||
// We are still loading the page, this means that because of crappy memory manager,
|
Draw_Window(); // stop button => refresh button
|
||||||
// the address of the HTTP data may change.
|
}
|
||||||
// Because this would result in pagefault when redrawing window while loading, we disable this possibility.
|
|
||||||
bufsize = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user