我检查了 Web 服务器的访问日志。itunessstored 应用程序询问了两次。(头部和获取)
10.0.2.2 - - [06/Feb/2014:14:50:48 +0900] "HEAD /test/app/app.ipa HTTP/1.1" 401 - "-" "itunesstored/1.0 iOS/7.0.4 model/iPhone4,1 (6; dt:73)"
10.0.2.2 - test [06/Feb/2014:14:51:03 +0900] "HEAD /test/app/app.ipa HTTP/1.1" 200 - "-" "itunesstored/1.0 iOS/7.0.4 model/iPhone4,1 (6; dt:73)"
10.0.2.2 - - [06/Feb/2014:14:51:04 +0900] "GET /test/app/app.ipa HTTP/1.1" 401 539 "-" "itunesstored/1.0 iOS/7.0.4 model/iPhone4,1 (6; dt:73)"
10.0.2.2 - test [06/Feb/2014:14:51:09 +0900] "GET /test/app/app.ipa HTTP/1.1" 200 4066787 "-" "itunesstored/1.0 iOS/7.0.4 model/iPhone4,1 (6; dt:73)"
因此,我更改了 Web 服务器的设置以在请求 HEAD 时忽略基本身份验证。
前:
<Directory "/Library/WebServer/Documents/test/app/">
AuthType Basic
AuthName "BASIC AUTH"
AuthUserFile "/etc/apache2/htpasswd"
Require valid-user
</Directory>
后:
SetEnvIf Request_Method HEAD headreq
<Directory "/Library/WebServer/Documents/test/app/">
Order Allow,Deny
Allow from env=headreq
AuthType Basic
AuthName "BASIC AUTH"
AuthUserFile "/etc/apache2/htpasswd"
Require valid-user
Satisfy Any
</Directory>
之后,itunessstored 应用程序只询问了一次。(仅获取)。