c# - VLC authentication using HttpWebRequest -


i'm trying use vlc's http interface read current playlist (get /requests/playlist.xml).

this working fine in older version of vlc, in recent versions added password option , made mandatory. (there no username.)

i first tried using this:

request.credentials = new networkcredential("", password); request.preauthenticate = true; 

however resulted in webexception reporting 401 error. snooping traffic revealed sent 1 request did not have authorization header, , reported error without attempting authenticate. (vlc did correctly respond www-authenticate challenge.)

if specify non-blank username, sends same request before follows second request specify authorization header -- fails because vlc rejects username.

i managed work setting header explicitly:

var credential = convert.tobase64string(encoding.default.getbytes(":" + password)); request.headers[httprequestheader.authorization] = "basic " + credential; 

this seems should have worked originally, though. bug in .net (or wininet), can't cope blank usernames; or bug in vlc, doesn't use username; or bug in code, needed set else?

i've had same issue, albeit i'm using empty string password. there tools such ilspy can use decompile .net libraries using can view source code. although haven't found anything, maybe can use determine if it's .net issue. i've had problem occur using both basic , digest authorization i'd take @ httpwebrequest (which assume using).

it seems setting authorization header manually way go now. since using basic, if care security of password, might want ssl if aren't implementing already.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -