[MPlayer-dev-eng] More On Automatic Codec Downloader

Felix Buenemann atmosfear at users.sourceforge.net
Sun Mar 10 20:10:20 CET 2002


Am Son, 2002-03-10 um 18.46 schrieb Gábor Lénárt:
> On Sun, Mar 10, 2002 at 06:30:51PM +0100, Arpi wrote:
> > I'm against perl... it is not as usual as you think, and it's very uncommon
> > with mplayer. There is an installer for mplayer, made by .so, check
> > out module 'installer' from mplayer cvs server:
> > cvs -d:...../cvsroot/mplayer co installer
> 
> Yes, and for example I don't know perl :) I've started to learn it several
> times but it's VERY ugly for me, so I always stopped learning it (C,assembly,
> and several script language - except perl - is enough for me).
> Perl flame thread ;-)
Perl rulez, the the ultimate script language available and no other
allows you to write such cool code, you just have to learn to think in
perl, then it's much fun to code it.

Btw. for post request you need to do a POST request (code is taken from
a commercial project of mine, converted to perl and changed for this
purpose):
Send this stuff to the opened socket at webservers port 80 in your
perlscript:
print SOCKETFILEHANDLE <<"EOF";
POST /url/to/some/cgi.dll HTTP/1.0
Connection: Keep-Alive
User-Agent: MPlayer Installer/1.0
Pragma: no-cache
Cache-control: no-cache
Accept: */*
Host: hostname.of.the.target.websever.com
Content-Type: application/x-www-form-urlencoded
Content-Length: length-of-the-request-body-in-bytes

here-starts-the-request-body-empty-line-above-is-needed
EOF

In above example you would need to send request body urlencoded with
var=value&var2=value etc.
This is for a standard web form, thex do not need to use
eee-form.urlencded stuff, they could simply send the stuff cleartext, so
sniff a request to see how exactly their post request looks alike (or
setup some dummy perlscript or netcat on local port 80 and pretend to be
the microsoft webserver by setting it's hostname to 127.0.0.1 in the
unix/windows hosts file.

Btw. here's the urlencode algorithm as snipplet from same commercial
project of mine (so code copyrighted by me ;), I didn't bother
translating it from vb here, because it's so simple and easy to
implement:

Private Function URLEncode(ClearText As String) As String
    ' This Function does a HTML-Form like URL-Encoding as
    ' used by HTTP-POST requests of HTML-Forms
    
    ' Description from PHP4 Manual [(c) by PHP Documentation Group]:
    ' A string in which all non-alphanumeric characters
    ' except -_. have been replaced with a percent (%) sign followed
    ' by two hex digits and spaces encoded as plus (+) signs. It is
    ' encoded the same way that the posted data from a WWW form is
    ' encoded, that is the same way as in
    ' application/x-www-form-urlencoded media type.
    
    Dim i As Long
    Dim EncText As String
    
    'ClearText = trim(ClearText)
     
    For i = 1 To Len(ClearText)
        Dim TmpStr As String
        
        TmpStr = Mid(ClearText, i, 1)
        Select Case Asc(TmpStr)
            Case 32
                EncText = EncText & "+"
            Case 45 To 46, 48 To 57, 65 To 90, 95, 61 To 122
                EncText = EncText & TmpStr
            Case 0 To 15
                EncText = EncText & "%0" & CStr(Hex(Asc(TmpStr)))
            Case Else
                EncText = EncText & "%" & CStr(Hex(Asc(TmpStr)))
        End Select
    Next
    
    URLEncode = EncText ' return encoded text
    
End Function

Btw. I know VB is ugly, but it's the only thing I'm currently capable of
coding gui win32 database apps with, this will hopefully soon change to
C++ (at least I can code -the-only-true-C- in MPlayer =))
> 
> - Gábor
> 
-- 
Best Regards,
	Atmos
____________________________________________
- MPlayer Developer - http://mplayerhq.hu/ -
____________________________________________




More information about the MPlayer-dev-eng mailing list