美文网首页
iOS技巧-Xcode7下AFNetworking请求发生404

iOS技巧-Xcode7下AFNetworking请求发生404

作者: 邓龙 | 来源:发表于2015-10-21 17:27 被阅读3434次

    1.问题描述

    function:__58-[ALHomePageViewController testRequestAppListWithOriginal]_block_invoke_2 line:214 content:<AFHTTPRequestOperation: 0x7fa8896b2a80, state: isFinished, cancelled: NO request: <NSMutableURLRequest: 0x7fa8896b2a70> { URL: http://services.ubtrobot.com:8081/opencenter/app/accessGetListByPage }, response: <NSHTTPURLResponse: 0x7fa88b82dd80> { URL: http://services.ubtrobot.com:8081/opencenter/app/accessGetListByPage } { status code: 404, headers {
        "Content-Length" = 0;
        Date = "Wed, 21 Oct 2015 21:19:08 GMT";
        Server = "Apache-Coyote/1.1";
        "Set-Cookie" = "JSESSIONID=A8A4C8BA39D8BE680D1A4E58C567754F; Path=/opencenter/; HttpOnly";
    } }>
    

    2.网络请求在第三方Paw连接正常

    网络请求正常.jpg

    3.解决办法

    方式一:在info.list的源码中添加(对本项目无效)

        <key>NSAppTransportSecurity</key>
        <dict>
            <key>NSAllowsArbitraryLoads</key>
            <true/>
        </dict>
    

    方式二:在info.list的源码中添加(实测对本项目有效)

        <key>NSAppTransportSecurity</key>
        <dict>
            <key>NSAllowsArbitraryLoads</key>
            <true/>
            <key>NSExceptionDomains</key>
            <dict>
                <key>NSIncludesSubdomains</key>
                <true/>
                <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
                <true/>
                <key>NSTemporaryExceptionMinimumTLSVersion</key>
                <string>TLSv1.1</string>
            </dict>
        </dict>
    

    相关文章

      网友评论

          本文标题:iOS技巧-Xcode7下AFNetworking请求发生404

          本文链接:https://www.haomeiwen.com/subject/nzcthttx.html