Lazarus: Set User-Agent in TFPHttpClient
Question by Guest | Last update on 2022-10-31 | Created on 2018-04-24
I am using the FPHttpClient to download some websites from the Internet with my Lazarus program.
Now I would like to customize the UserAgent, which is used in the header of my request when retrieving a site. Is there any possibility do adjust this?
Related Topics
MySQL: Line Breaks in MySQL
Tip | 0 Comments
Delphi/Lazarus: How to set up a Link to a Website in an Application
Tutorial | 0 Comments
Delphi/Lazarus: Password Edit
Tip | 0 Comments
VirtualBox: Change Date and Time
Tutorial | 10 Comments
Windows Batch Script: Computer Shutdown
Tutorial | 2 Comments
Delphi/Lazarus: Dynamically create a Label at runtime
Tip | 0 Comments
Important Note
Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.
Participate
Ask your own question or write your own article on askingbox.com. That’s how it’s done.
The TFPHttpClient provides the AddHeader function, which allows you to add any headers you want to your request.
AddHeader takes two parameters, the name of the header and the value. To set the user agent for example to Mozilla/5.0, it would be this:
Altogether, the call can be implemented like that:
Of course, instead of Mozilla/5.0, you can also pass any other string of your desire.
Last update on 2022-10-31 | Created on 2018-04-25