Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
Networking and Web Programming
»
timelimit for HTTPMethod
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
Forum Rules
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
QGradientTrackPanel: A Fu...
by
Boleeman
[
Today
at 07:13:07 am]
[closed] Is case for stri...
by
egsuh
[
Today
at 06:39:17 am]
New charts
by
Boleeman
[
Today
at 04:26:40 am]
Unleashed Pascal (async/a...
by
Akira1364
[
Today
at 02:24:26 am]
Fast Canvas Library V1.05...
by
Gigatron
[
Today
at 01:28:23 am]
How to define the SQLite3...
by
jamie
[
Today
at 01:26:49 am]
kOmniXML for Lazarus and ...
by
PeterEvans
[
Today
at 01:11:14 am]
Finding List of Fonts & P...
by
J-G
[August 09, 2026, 11:05:31 pm]
[Scrubbed] Question about...
by
jamie
[August 09, 2026, 08:47:34 pm]
Bug: XLSX writer does not...
by
wp
[August 09, 2026, 08:29:22 pm]
New Big Integer library i...
by
ad1mt
[August 09, 2026, 05:32:14 pm]
Star Wars Galaxian
by
Thausand
[August 09, 2026, 04:47:51 pm]
Automatic generation of *...
by
PeterBB
[August 09, 2026, 01:38:51 pm]
TyControls: a custom-draw...
by
Antek
[August 09, 2026, 12:07:39 pm]
PO-Editor MyLangEdit3 now...
by
dbannon
[August 09, 2026, 07:55:47 am]
Application triggers mess...
by
JanRoza
[August 09, 2026, 12:26:52 am]
[solved] form reset/reloa...
by
ADMGNS
[August 08, 2026, 09:58:42 pm]
Create small language
by
ADMGNS
[August 08, 2026, 09:52:19 pm]
Advatage Database server
by
neobrasil08
[August 08, 2026, 08:42:18 pm]
How get listy of FieldDat...
by
Aruna
[August 08, 2026, 04:02:16 pm]
Identify network devices
by
LemonParty
[August 08, 2026, 03:44:03 pm]
how to connect to mariadb...
by
Mike.Cornflake
[August 08, 2026, 12:25:31 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: timelimit for HTTPMethod (Read 1657 times)
DeroB73
Newbie
Posts: 6
timelimit for HTTPMethod
«
on:
December 07, 2019, 09:15:21 pm »
Hello
is it possible to set a time limit for the Synapse HTTPMethod GET method ?
I am trying a huge list from URLs to see i they are still alive.
TTPMethod('GET','
http://123.123.123/index
.') works great as long status is 200 but for dead links 400 it takes 2 a 3 seconds that's to long.
Greets
Logged
fjabouley
Full Member
Posts: 129
Re: timelimit for HTTPMethod
«
Reply #1 on:
December 07, 2019, 09:33:18 pm »
Try to add HTTP.Sock.ConnectionTimeout
Code: Pascal
[Select]
[+]
[-]
Function
Getwithtimeout
(
URL
:
string
;
Default_timeout
:
integer
=
1000
)
:
string
;
var
response
:
Tstringlist
;
var
HTTP
:
THTTPSend
;
begin
Result
:
=
''
;
Response
:
=
TStringList
.
Create
;
HTTP
:
=
THTTPSend
.
Create
;
HTTP
.
Timeout
:
=
Default_timeout
;
HTTP
.
Sock
.
ConnectionTimeout
:
=
Default_timeout
;
if
HTTP
.
HTTPMethod
(
'GET'
,
URL
)
then
begin
if
HTTP
.
ResultCode
<>
200
then
begin
// Error : do some stuff
end
else
begin
Response
.
LoadFromStream
(
HTTP
.
Document
)
;
Result
:
=
response
.
Text
;
end
;
end
;
Response
.
Free
;
HTTP
.
Free
;
end
;
or
Code: Pascal
[Select]
[+]
[-]
Function
IsCorrectURL
(
URL
:
string
;
Default_timeout
:
integer
=
1000
)
:
boolean
;
var
response
:
Tstringlist
;
var
HTTP
:
THTTPSend
;
begin
Result
:
=
false
;
HTTP
:
=
THTTPSend
.
Create
;
HTTP
.
Timeout
:
=
Default_timeout
;
HTTP
.
Sock
.
ConnectionTimeout
:
=
Default_timeout
;
if
HTTP
.
HTTPMethod
(
'GET'
,
URL
)
then
if
HTTP
.
ResultCode
=
200
then
Result
:
=
true
;
HTTP
.
Free
;
end
;
«
Last Edit: December 07, 2019, 09:41:56 pm by fjabouley
»
Logged
DeroB73
Newbie
Posts: 6
Re: timelimit for HTTPMethod
«
Reply #2 on:
December 08, 2019, 12:47:52 pm »
thanks fjabouley
it seems i have learn Synapse more in dept.
Logged
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
Networking and Web Programming
»
timelimit for HTTPMethod
TinyPortal
© 2005-2018