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
Need help converting a C+...
by
srvaldez
[
Today
at 12:02:59 pm]
[BUG REPORT] Code explore...
by
BlackVoid
[
Today
at 10:44:49 am]
Probleme installing Lazar...
by
DonAlfredo
[
Today
at 09:05:41 am]
$ifdef highlighting
by
paweld
[
Today
at 08:49:14 am]
Wikipedia pollution
by
Thaddy
[
Today
at 08:31:35 am]
How to register a windows...
by
Thaddy
[
Today
at 08:24:15 am]
Please ask about the valu...
by
Thaddy
[
Today
at 08:17:37 am]
TurboBird IBX
by
rvk
[
Today
at 07:10:47 am]
laz_xmlstreaming.pas fail...
by
Ryan J
[
Today
at 05:51:09 am]
append new record to arra...
by
speter
[
Today
at 12:46:02 am]
TTagEdit Component 1.2
by
astverskoy
[December 06, 2025, 11:25:09 pm]
Dumb Problems Contest!
by
Bart
[December 06, 2025, 11:08:05 pm]
Corrupted strings
by
Aruna
[December 06, 2025, 08:25:44 pm]
Convert string with Key-V...
by
Bart
[December 06, 2025, 08:07:00 pm]
Lazarus Trunc & macOS Tah...
by
Thaddy
[December 06, 2025, 05:00:57 pm]
"F2": possible bug in IDE...
by
WooBean
[December 06, 2025, 04:14:47 pm]
Problem with TSQLQuery
by
sch61
[December 06, 2025, 02:53:10 pm]
Lazarus broke my project
by
LatinoDaddy
[December 06, 2025, 02:21:02 pm]
How to use nested classes
by
Thaddy
[December 06, 2025, 02:03:44 pm]
Publish a LAMW app in F-d...
by
Joris
[December 06, 2025, 01:49:23 pm]
Help with a TPages and TA...
by
AlexTP
[December 06, 2025, 12:01:24 pm]
randomrange
by
BubikolRamios
[December 06, 2025, 10:36:19 am]
Synedit wordwrap
by
Martin_fr
[December 06, 2025, 09:42:04 am]
How to load read large CS...
by
Xenno
[December 06, 2025, 05:43:10 am]
Uno, working demo (comput...
by
TBMan
[December 06, 2025, 04:18:51 am]
« previous
next »
Print
Pages: [
1
]
Author
Topic: timelimit for HTTPMethod (Read 1545 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