-
MY PROJECTS
-
Recent Posts
- SpringBoot.Making our first starter and autoconfiguration
- Spring. Creating main annotation to start business logic
- Spring.Reading from properties file
- Spring.How to define spring version inside springBoot ?
- SpringBoot App inside Docker
- Kafka.FirstExperience
- Docker.MySql and Lost connection to MySQL server at ‘reading initial communication packet’, system error: 0
- Gradle.Tips
- Spring.AppConfig
- Leetcode.Best-time-to-buy-and-sell-stock
- LeetCode.ClimbStairs.Fibbonacci
- Leetcode.Roman-to-integer
- LeetCode.Palindrome-number
- Java.DesignPatterns.Lightweight
- Java.DesignPatterns.Proxy
- Java.DesignPatterns.Facade
- Java.DesignPatterns.Composite
- Java.DesignPatterns.Bridge
- Java. Strange OOP thing
- Java.Classpath
Categories
- Aptana
- Azure
- C#
- DataSnap
- DBExpress
- Delphi
- Delphi и сети
- Delphi. Язык программирования
- ExtJS
- FastReport
- FireDAC
- FireMonkey
- GIT
- ICS
- IDE
- IIS
- Indy
- InnoSetup
- javascript
- jQuery
- JSON
- LiveBindings
- MSHTML
- MySQL
- PHP
- REST
- Ribbons
- SMS
- SQL инструкции
- SVN
- TRichView
- UniGui
- WebBroker
- WinAPI
- Windows
- Алгоритмы
- Без рубрики
- Деревья
- Ищу ответ
- Компонентостроение
- Мои компоненты
- Начальный уровень
- Обработка исключений
- Парсинг
- Потоки(Threads)
- Регулярные выражения
- Тестирование приложений
Daily Archives: 08.11.2016
Delphi. Как заставить idHTTPServer отображать страницы или отдавать на загрузку файлы?
У меня получился такой вариант Вот главный кусок, который отвечает за отображение веб-страниц, либо отдачу файла
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
procedure TfHTTPServer.IdHTTPServerCommandGet(AContext: TIdContext; ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo); var filepath: string; IsWebPage: Boolean; WebPageContent: string; begin //...some code //Preparing file for download if it is on the Server begin if FHTTPServerCommandGet.IsFileOnServer(ARequestInfo.URI,filepath,IsWebPage,WebPageContent) then begin AResponseInfo.ResponseNo := 200; if IsWebPage then AResponseInfo.ContentText:=WebPageContent else AResponseInfo.ServeFile(AContext, filepath); end else AresponseInfo.ResponseNo := 404; end; end; |
В отдельном модуле метод проверки наличия файла на сервере