Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2011-04

Error 500

13 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

silvioprog

Hi.

In a simple CGI app, I try to use TFreeTypeFont class, but without success. The error returned is "Error 500"(see log in [1]).

In attached I send a small sample to reproduce the error.

*Lazarus 0.9.31 r30005 FPC 2.5.1 i386-win32-win32/win64 / XAMPP 1.7.3! on Windows Seven 64.*

Thx.

[1]:
---------------------------
Date: Tue, 05 Apr 2011 14:54:11 GMT
Server: Apache/2.2.14 (Win32) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l mod_autoindex_color PHP/5.3.1 mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1
Vary: accept-language,accept-charset
Accept-Ranges: bytes
Connection: close
Content-Type: text/html; charset=iso-8859-1
Content-Language: pt-br
---------------------------

500 Internal Server Error

Silvio Cl?cio ============================================= Blog - silvioprog.com.br Twitter - twitter.com/silvioprog LazSolutions - code.google.com/p/lazsolutions Lazarus-BR - groups.google.com.br/group/lazarus-br?hl=pt-BR ============================================= -------------- next part -------------- A non-text attachment was scrubbed... Name: FreeTypeFontError.zip Type: application/zip Size: 2317 bytes Desc: not available URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110405/6fe0b919/attachment.zip>

Reply by email

silvioprog
to silvioprog

2011/4/5 silvioprog :

Show quoted text 26 lines
Hi. In a simple CGI app, I try to use TFreeTypeFont class, but without success. The error returned is "Error 500"(see log in [1]). In attached I send a small sample to reproduce the error. *Lazarus 0.9.31 r30005 FPC 2.5.1 i386-win32-win32/win64 / XAMPP 1.7.3! on Windows Seven 64.* Thx. [1]: --------------------------- Date: Tue, 05 Apr 2011 14:54:11 GMT Server: Apache/2.2.14 (Win32) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l mod_autoindex_color PHP/5.3.1 mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1 Vary: accept-language,accept-charset Accept-Ranges: bytes Connection: close Content-Type: text/html; charset=iso-8859-1 Content-Language: pt-br --------------------------- 500 Internal Server Error

I'm trying to write a text in an image and show in the browser. This code[1] not works (returns error 500).

[1] (http:/msg18488/t.pp):
uses

  FPCanvas, FPImage, FPImgCanv, FTFont, FPWritePNG;
var
  img: TFPMemoryImage;
  c: TFPImageCanvas;
  f: TFreeTypeFont;
begin
  img := TFPMemoryImage.Create(500, 100);
  c := TFPImageCanvas.Create(img);
  f := TFreeTypeFont.Create;
  c.Clear;
  c.Pen.FPColor := colRed;
  f.Name := 'Times';
  f.Size := 14;
  f.FPColor := colRed;
  c.Font := f;
  c.TextOut(10, 20, 'sample text 12345');
  img.SaveToFile('test.png');
  f.Free;
  c.Free;
  img.Free;
end.
Silvio Cl?cio ============================================= Blog - silvioprog.com.br Twitter - twitter.com/silvioprog LazSolutions - code.google.com/p/lazsolutions Lazarus-BR - groups.google.com.br/group/lazarus-br?hl=pt-BR =============================================

Reply by email

Mattias Gaertner
to silvioprog
Show quoted text 30 lines
2011/4/5 silvioprog : > Hi. > > In a simple CGI app, I try to use TFreeTypeFont class, but without success. > The error returned is "Error 500"(see log in [1]). > > In attached I send a small sample to reproduce the error. > > *Lazarus 0.9.31 r30005 FPC 2.5.1 i386-win32-win32/win64 / XAMPP 1.7.3! > on Windows Seven 64.* > > Thx. > > [1]: > --------------------------- > Date: Tue, 05 Apr 2011 14:54:11 GMT > Server: Apache/2.2.14 (Win32) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l > mod_autoindex_color PHP/5.3.1 mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 > Perl/v5.10.1 > Vary: accept-language,accept-charset > Accept-Ranges: bytes > Connection: close > Content-Type: text/html; charset=iso-8859-1 > Content-Language: pt-br > --------------------------- > > 500 Internal Server Error I'm trying to write a text in an image and show in the browser. This code[1] not works (returns error 500).

Look into your apache logs for more details.

Show quoted text 20 lines
[1] (http:/msg18488/t.pp): uses FPCanvas, FPImage, FPImgCanv, FTFont, FPWritePNG; var img: TFPMemoryImage; c: TFPImageCanvas; f: TFreeTypeFont; begin img := TFPMemoryImage.Create(500, 100); c := TFPImageCanvas.Create(img); f := TFreeTypeFont.Create; c.Clear; c.Pen.FPColor := colRed; f.Name := 'Times'; f.Size := 14; f.FPColor := colRed; c.Font := f; c.TextOut(10, 20, 'sample text 12345'); img.SaveToFile('test.png');

Has the cgi script write permissions when running as apache user?

f.Free; c.Free; img.Free; end.

Mattias

Reply by email

Michael Van Canneyt
to Mattias Gaertner
Mattias Gaertner wrote 52 lines
On Tue, 5 Apr 2011 12:14:58 -0300 silvioprog wrote: > 2011/4/5 silvioprog : >> Hi. >> >> In a simple CGI app, I try to use TFreeTypeFont class, but without success. >> The error returned is "Error 500"(see log in [1]). >> >> In attached I send a small sample to reproduce the error. >> >> *Lazarus 0.9.31 r30005 FPC 2.5.1 i386-win32-win32/win64 / XAMPP 1.7.3! >> on Windows Seven 64.* >> >> Thx. >> >> [1]: >> --------------------------- >> Date: Tue, 05 Apr 2011 14:54:11 GMT >> Server: Apache/2.2.14 (Win32) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l >> mod_autoindex_color PHP/5.3.1 mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 >> Perl/v5.10.1 >> Vary: accept-language,accept-charset >> Accept-Ranges: bytes >> Connection: close >> Content-Type: text/html; charset=iso-8859-1 >> Content-Language: pt-br >> --------------------------- >> >> 500 Internal Server Error > > I'm trying to write a text in an image and show in the browser. This > code[1] not works (returns error 500). Look into your apache logs for more details. > [1] (http:/msg18488/t.pp): > uses > FPCanvas, FPImage, FPImgCanv, FTFont, FPWritePNG; > > var > img: TFPMemoryImage; > c: TFPImageCanvas; > f: TFreeTypeFont; > begin > img := TFPMemoryImage.Create(500, 100); > c := TFPImageCanvas.Create(img); > f := TFreeTypeFont.Create; > c.Clear; > c.Pen.FPColor := colRed; > f.Name := 'Times';

Where do you load the font path ?
I miss things like

   ftFont.InitEngine;
   FontMgr.SearchPath:='/usr/lib/X11/fonts/truetype';

or on windows

   FontMgr.SearchPath:='c\windows\fonts';
Show quoted text 7 lines
> f.Size := 14; > f.FPColor := colRed; > c.Font := f; > c.TextOut(10, 20, 'sample text 12345'); > img.SaveToFile('test.png'); Has the cgi script write permissions when running as apache user?

It is on windows, so it should be OK.

Michael.

Reply by email

silvioprog
to Mattias Gaertner: On Tue, 5 Apr 2011 12:14:58 -0300 Look into your apache logs for more details. Has the…

2011/4/5 Mattias Gaertner :

Look into your apache logs for more details.

The logs:

In C:\xampp\apache\logs\access.log:
----------------------------------
::1 - - [05/Apr/2011:20:48:45 -0300] "GET /cgi-bin/bug.cgi HTTP/1.1" 500 1319 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0) Gecko/20100101 Firefox/4.0"
----------------------------------

In C:\xampp\apache\logs\error.log:
----------------------------------
(...)
[Tue Apr 05 20:47:33 2011] [notice] Child 5472: Starting thread to listen on port 80.
[Tue Apr 05 20:47:33 2011] [notice] Child 5472: Starting thread to listen on port 80.
[Tue Apr 05 20:48:45 2011] [error] [client ::1] Premature end of script headers: bug.cgi
----------------------------------

Has the cgi script write permissions when running as apache user? Mattias

Yes. My UAC is totaly disabled on Windows.

To tests, I downloaded this DLL[1], and I put in
"C:\xampp\cgi-bin\freetype-6.dll" and
"C:\Windows\system32\freetype-6.dll".

[1] http://www.dlldump.com/download-dll-files_new.php/dllfiles/F/freetype6.dll/2.1.7.1505r/download.html

I changed my code to:

procedure TMainFPWebModule.indexRequest(Sender: TObject; ARequest: TRequest;
  AResponse: TResponse; var Handled: Boolean);
begin
  Handled := True;
  InitEngine; // If I comment this line, the error disappears. :o
end;
Silvio Cl?cio ============================================= Blog - silvioprog.com.br Twitter - twitter.com/silvioprog LazSolutions - code.google.com/p/lazsolutions Lazarus-BR - groups.google.com.br/group/lazarus-br?hl=pt-BR =============================================

Reply by email

silvioprog
to Michael Van Canneyt: Where do you load the font path ? I miss things like ftFont.InitEngine;…

2011/4/5 Michael Van Canneyt :

Show quoted text 9 lines
Where do you load the font path ? I miss things like ?ftFont.InitEngine; ?FontMgr.SearchPath:='/usr/lib/X11/fonts/truetype'; or on windows ?FontMgr.SearchPath:='c\windows\fonts';

In fonts of Windows:

procedure TMainFPWebModule.indexRequest(Sender: TObject; ARequest: TRequest;
  AResponse: TResponse; var Handled: Boolean);
begin
  Handled := True;
  ftFont.InitEngine; // <<-- Error is here. :(
  FontMgr.SearchPath := 'C:\WINDOWS\Fonts\';
end;
Michael.

How I get a "full log" with CGIs erros?

Silvio Cl?cio ============================================= Blog - silvioprog.com.br Twitter - twitter.com/silvioprog LazSolutions - code.google.com/p/lazsolutions Lazarus-BR - groups.google.com.br/group/lazarus-br?hl=pt-BR =============================================

Reply by email

Graeme Geldenhuys
to silvioprog
silvioprog wrote
How I get a "full log" with CGIs erros?

I log all things, and exceptions to a log file in a temp directory (just while developing the cgi app). Alternatively you can log to a debugserver too - see the dbugintf unit in FCL.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

Lukasz Sokol
to silvioprog: 2011/4/5 Mattias Gaertner : The logs: In C:\xampp\apache\logs\access.log:…
silvioprog wrote 7 lines
procedure TMainFPWebModule.indexRequest(Sender: TObject; ARequest: TRequest; AResponse: TResponse; var Handled: Boolean); begin Handled := True; InitEngine; // If I comment this line, the error disappears. :o end;

Just a thought:

Alexander Klenin wrote 9 lines
On Wed, Apr 6, 2011 at 09:11, Michael Van Canneyt wrote: > > > > or on windows > > > > FontMgr.SearchPath:='c\windows\fonts'; On Windows this is done in the initializtion section of FTFont unit. -- Alexander S. Klenin

Maybe the initialization is already done somewhere i.e. you don't need to run it twice ?

L.

Reply by email

silvioprog
to Graeme Geldenhuys: I log all things, and exceptions to a log file in a temp directory (just while developing…

2011/4/6 Graeme Geldenhuys :

Show quoted text 9 lines
I log all things, and exceptions to a log file in a temp directory (just while developing the cgi app). Alternatively you can log to a debugserver too - see the dbugintf unit in FCL. Regards, ?- Graeme - -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

I'm using debugserver (http://goo.gl/jHrSH), is a very good tool.

ps. Hm... my CGI app is still with error 500. :(

Thx.

Silvio Cl?cio ============================================= Blog - silvioprog.com.br Twitter - twitter.com/silvioprog LazSolutions - code.google.com/p/lazsolutions Lazarus-BR - groups.google.com.br/group/lazarus-br?hl=pt-BR =============================================

Reply by email

Graeme Geldenhuys
to silvioprog
silvioprog wrote
I'm using debugserver (http://goo.gl/jHrSH), is a very good tool.

WARNING:
Be careful with debugserver under Windows - you can't always trust the results. If you have a process that runs fast, and generates a lot of debug messages (many per second), debugserver looses many of those messages. I reported this bug, but can't find it in Mantis now (Mantis searching sucks).

ps. Hm... my CGI app is still with error 500. :(

I would suggest you look at Apache log files, and maybe place SendDebug() calls inside your application to see what it executes before the error - narrowing down it's location. I feel your pain... debugging CGI apps are a nightmare! Yet another reason I hate web applications. :)

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

Michael Van Canneyt
to Graeme Geldenhuys
Graeme Geldenhuys wrote 19 lines
On 07/04/2011 00:06, silvioprog wrote: > > I'm using debugserver (http://goo.gl/jHrSH), is a very good tool. WARNING: Be careful with debugserver under Windows - you can't always trust the results. If you have a process that runs fast, and generates a lot of debug messages (many per second), debugserver looses many of those messages. I reported this bug, but can't find it in Mantis now (Mantis searching sucks). > ps. Hm... my CGI app is still with error 500. :( I would suggest you look at Apache log files, and maybe place SendDebug() calls inside your application to see what it executes before the error - narrowing down it's location. I feel your pain... debugging CGI apps are a nightmare! Yet another reason I hate web applications. :)

There are 2 solutions:
- FastCGI
- Embedded webserver
Both can easily be debugged, and the final result can still be a CGI app. With some extra work you can have 1 binary that functions as the 3 types of app.

Michael.

Reply by email

silvioprog
to Graeme Geldenhuys: WARNING: Be careful with debugserver under Windows - you can't always trust the results. …

2011/4/7 Graeme Geldenhuys :

Show quoted text 26 lines
On 07/04/2011 00:06, silvioprog wrote: > > I'm using debugserver (http://goo.gl/jHrSH), is a very good tool. WARNING: Be careful with debugserver under Windows - you can't always trust the results. ?If you have a process that runs fast, and generates a lot of debug ?messages ?(many ?per ?second), debugserver looses many of those messages. I reported this bug, but can't find it in Mantis now (Mantis searching sucks). > ps. Hm... my CGI app is still with error 500. :( I ?would ?suggest ?you ?look ?at ?Apache ?log ?files, ?and maybe place SendDebug() ?calls ?inside ?your ?application ?to see what it executes before ?the ?error - narrowing down it's location. I feel your pain... debugging ?CGI ?apps ?are ?a ?nightmare! Yet another reason I hate web applications. :) Regards, ?- Graeme - -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Case I solves the problem, I'll post here. ;)

Thanks. :)

Silvio Cl?cio ============================================= Blog - silvioprog.com.br Twitter - twitter.com/silvioprog LazSolutions - code.google.com/p/lazsolutions Lazarus-BR - groups.google.com.br/group/lazarus-br?hl=pt-BR =============================================

Reply by email