@@ -28,11 +28,11 @@ export default class HTTPDigestAuth {
2828
2929 getChallenge ( context ) {
3030 var RE = {
31- realm : / r e a l m = " ? ( [ ^ " ] + ) " ? / ,
32- nonce : / n o n c e = " ? ( [ ^ " ] + ) " ? / ,
33- qop : / q o p = " ? ( [ ^ " ] + ) " ? / ,
34- algorithm : / a l g o r i t h m = " ? ( [ ^ " ] + ) " ? / ,
35- opaque : / o p a q u e = " ? ( [ ^ " ] + ) " ? / ,
31+ realm : / r e a l m = " ? ( [ ^ " ^ , ] + ) " ? / ,
32+ nonce : / n o n c e = " ? ( [ ^ " ^ , ] + ) " ? / ,
33+ qop : / q o p = " ? ( [ ^ " ^ , ] + ) " ? / ,
34+ algorithm : / a l g o r i t h m = " ? ( [ ^ " ^ , ] + ) " ? / ,
35+ opaque : / o p a q u e = " ? ( [ ^ " ^ , ] + ) " ? / ,
3636 }
3737
3838 //noinspection JSUnresolvedFunction
@@ -41,6 +41,11 @@ export default class HTTPDigestAuth {
4141 const request = new NetworkHTTPRequest ( )
4242 request . requestUrl = currentRequest . url
4343 request . method = currentRequest . method
44+ let currentUserAgent = currentRequest . getHeaderByName ( 'User-Agent' )
45+ if ( currentUserAgent == null ) {
46+ currentUserAgent = "Paw/" + bundle . appVersion + " (Macintosh; OS X/" + bundle . osVersion + ") GCDHTTPRequest"
47+ }
48+ request . setRequestHeader ( 'User-Agent' , currentUserAgent )
4449 request . send ( )
4550 const WWWAuthenticate = request . getResponseHeader ( 'WWW-Authenticate' )
4651 Immutable . Map ( RE ) . forEach ( ( re , key ) => {
@@ -143,8 +148,8 @@ export default class HTTPDigestAuth {
143148 else {
144149 this . nonce_count = 1
145150 }
146- let ncvalue = this . nonce_count
147- let cnonce = this . getNonce ( )
151+ let ncvalue = '00000001'
152+ let cnonce = this . getNonce ( )
148153 if ( _algorithm === 'MD5-SESS' ) {
149154 HA1 = hash_utf8 ( `${ HA1 } :${ nonce } :${ cnonce } ` )
150155 }
@@ -170,13 +175,13 @@ export default class HTTPDigestAuth {
170175 base += `, opaque="${ opaque } "`
171176 }
172177 if ( algorithm ) {
173- base += `, algorithm=" ${ algorithm } " `
178+ base += `, algorithm=${ algorithm } `
174179 }
175180 if ( entdig ) {
176181 base += `, digest="${ entdig } "`
177182 }
178183 if ( qop ) {
179- base += `, qop=" auth" , nc=${ ncvalue } , cnonce="${ cnonce } "`
184+ base += `, qop=auth, nc=${ ncvalue } , cnonce="${ cnonce } "`
180185 }
181186
182187 return `Digest ${ base } `
0 commit comments