LazMapViewer: Add URL encoding method to DownloadEngine to fix failure in searching for city names with unsafe characters in mvGeoNames unit.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9302 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
67d62d9719
commit
30180acdfb
@ -921,7 +921,6 @@ object MainForm: TMainForm
|
||||
NoneColorColor = clWhite
|
||||
Style = [cbStandardColors, cbExtendedColors, cbIncludeNone, cbCustomColor, cbPrettyNames, cbCustomColors]
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
AutoSize = False
|
||||
BorderSpacing.Left = 6
|
||||
ItemHeight = 10
|
||||
TabOrder = 10
|
||||
|
||||
@ -38,9 +38,9 @@ object MainForm: TMainForm
|
||||
Height = 662
|
||||
Top = 0
|
||||
Width = 275
|
||||
ActivePage = PgConfig
|
||||
ActivePage = PgData
|
||||
Align = alRight
|
||||
TabIndex = 2
|
||||
TabIndex = 0
|
||||
TabOrder = 1
|
||||
object PgData: TTabSheet
|
||||
Caption = 'Data'
|
||||
|
||||
@ -16,7 +16,7 @@ unit mvDLESynapse;
|
||||
interface
|
||||
|
||||
uses
|
||||
mvDownloadEngine, SysUtils, Classes, ssl_openssl, httpsend;
|
||||
mvDownloadEngine, SysUtils, Classes, ssl_openssl, synacode, httpsend;
|
||||
|
||||
type
|
||||
|
||||
@ -33,6 +33,7 @@ type
|
||||
procedure InternalDownloadFile(const Url: string; str: TStream); override;
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
function EncodeURLElement(const s: String): String; override;
|
||||
procedure SetProxy(AUseSystemProxy, AUseProxy: Boolean; AProxyHost: String;
|
||||
AProxyPort: Word; AProxyUserName, AProxyPassword: String); override;
|
||||
published
|
||||
@ -65,6 +66,11 @@ begin
|
||||
FSystemProxySupport := false;
|
||||
end;
|
||||
|
||||
function TMvDESynapse.EncodeURLElement(const s: String): String;
|
||||
begin
|
||||
Result := synacode.EncodeURLElement(s);
|
||||
end;
|
||||
|
||||
procedure TMvDESynapse.InternalDownloadFile(const Url: string; str: TStream);
|
||||
var
|
||||
FHttp: THTTPSend;
|
||||
|
||||
@ -41,6 +41,7 @@ type
|
||||
procedure InternalDownloadFile(const Url: string; AStream: TStream); override;
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
function EncodeURLElement(const s: String): String; override;
|
||||
procedure SetProxy(AUseSystemProxy, AUseProxy: Boolean; AProxyHost: String;
|
||||
AProxyPort: Word; AProxyUserName, AProxyPassword: String); override;
|
||||
{$IF FPC_FullVersion >= 30101}
|
||||
@ -76,6 +77,11 @@ begin
|
||||
FSystemProxySupport := false;
|
||||
end;
|
||||
|
||||
function TMvDEFpc.EncodeURLElement(const s: String): String;
|
||||
begin
|
||||
Result := fpHttpClient.EncodeURLElement(s);
|
||||
end;
|
||||
|
||||
procedure TMVDEFPC.InternalDownloadFile(const Url: string; AStream: TStream);
|
||||
var
|
||||
http: TFpHttpClient;
|
||||
|
||||
@ -30,6 +30,7 @@ type
|
||||
procedure LoadFromLocalFile(const AFileName: String; AStream: TStream);
|
||||
public
|
||||
procedure DownloadFile(const Url: string; AStream: TStream); virtual;
|
||||
function EncodeURLElement(const s: String): String; virtual;
|
||||
procedure SetProxy(AUseSystemProxy, AUseProxy: Boolean; AProxyHost: String;
|
||||
AProxyPort: Word; AProxyUserName, AProxyPassword: String); virtual; abstract;
|
||||
property HasProxySupport: Boolean read FProxySupport;
|
||||
@ -54,6 +55,11 @@ begin
|
||||
InternalDownloadFile(Url, AStream);
|
||||
end;
|
||||
|
||||
function TMvCustomDownloadEngine.EncodeURLElement(const s: String): String;
|
||||
begin
|
||||
Result := s;
|
||||
end;
|
||||
|
||||
procedure TMvCustomDownloadEngine.LoadFromLocalFile(const AFileName: String;
|
||||
AStream: TStream);
|
||||
var
|
||||
|
||||
@ -62,7 +62,7 @@ type
|
||||
implementation
|
||||
|
||||
uses
|
||||
FastHtmlParser;
|
||||
FastHtmlParser, FPHttpClient;
|
||||
|
||||
const
|
||||
SEARCH_URL = 'http://geonames.org/search.html?q=%s'; //&country=%s';
|
||||
@ -204,7 +204,7 @@ begin
|
||||
FLocationName := ALocationName;
|
||||
ms := TMemoryStream.Create;
|
||||
try
|
||||
url := Format(SEARCH_URL, [FLocationName]);
|
||||
url := Format(SEARCH_URL, [ADownloadEngine.EncodeURLElement(FLocationName)]);
|
||||
ADownloadEngine.DownloadFile(url, ms);
|
||||
ms.Position := 0;
|
||||
SetLength(s, ms.Size);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user