我正在使用dagger,Rx,MVP和retrofit2创建新的示例应用程序。我是改造中的新手。对于loginActivity我已经将参数作为json字符串发送到web服务。如果用户存在且有权限,服务返回 true 在body和header中发送Cookie:
// $day appears to be a Carbon date instance defined elsewhere that represents the first time on the day on which the slots are to be generated
foreach ( range( $lower, $upper, $step ) as $increment ) {
$times[] = $day->addSeconds($step)->format('YmdHi');
}
这是我的ApiService:
D/Payesh: --> POST http://test.com/Authentication.svc/json/Login
D/Payesh: Content-Type: application/json; charset=utf-8
D/Payesh: Content-Length: 183
D/Payesh: {"username":"****","password":"***","customCredential":"****","isPersistent":false}
D/Payesh: --> END POST (183-byte body)
/data/data/com.groot.payesh/cache/okhttp_cache/journal.tmp
D/Payesh: <-- 200 OK http://test.com/Authentication.svc/json/Login (2111ms)
D/Payesh: Cache-Control: private
D/Payesh: Content-Type: application/json; charset=utf-8
D/Payesh: Server: Microsoft-IIS/8.5
D/Payesh: Set-Cookie: ASP.NET_SessionId=3pi1nyrozbjwagw543Wsck4; path=/
D/Payesh: Set-Cookie: .ASPXAUTH=EA9127C4A3002F1D5EA5AADC279....; expires=Tue, 27-Mar-2018 15:17:22 GMT; path=/
D/Payesh: X-Frame-Options: SAMEORIGION
D/Payesh: Access-Control-Allow-Origin: test.com
D/Payesh: Access-Control-Allow-Headers: Content-Type, Accept
D/Payesh: Access-Control-Allow-Methods: GET, POST
D/Payesh: Access-Control-Max-Age: 1728000
D/Payesh: Access-Control-Allow-Credentials: true
D/Payesh: Date: Mon, 26 Mar 2018 15:17:22 GMT
D/Payesh: Content-Length: 4
D/Payesh: true
D/Payesh: <-- END HTTP (4-byte body)
此方法返回一个字符串,当我运行我的应用程序获取用户并通过时,我收到 True 。 这是我的观察员方法:
@POST(UrlManager.AUTHENTICATION+"Login")
Observable<String> getAuthentication(@Body RequestBody params);
我在标题中需要这一行:
Set-Cookie:.ASPXAUTH = EA9127C4A3002F1D5EA5AADC279 ....; expires =星期二,27-Mar-2018 15:17:22 GMT;路径= /
这是我的拦截器,用我的应用程序类中的匕首初始化:
public DisposableObserver<String> observer() {
return new DisposableObserver<String>() {
@Override
public void onNext(String responseBody) {
Log.i("--->", "onNext: " + responseBody);
}...
如何获得 Set-Cookie 值?