Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

一个网址本地缓存的问题。 #14

Closed
CXTretar opened this issue Jun 14, 2018 · 7 comments
Closed

一个网址本地缓存的问题。 #14

CXTretar opened this issue Jun 14, 2018 · 7 comments
Labels

Comments

@CXTretar
Copy link

测试Demo时发现,假如第一次安装后未打开任何新网址,在下次启动Demo时,会出现首页加载白屏,发现加载的网址是http://localhost:0/about/sessionrestore?history={"history":["about:homepage"],"currentPage":0} ; 作者大大有时间可以说明一下用 GCDWebServer 缓存网页浏览记录的原理么?

@CXTretar
Copy link
Author

CXTretar commented Jun 14, 2018

将server 的端口配置方法

- (BOOL)start{
    if (!_server.isRunning) {
        [self.server startWithOptions:@{
                                        GCDWebServerOption_Port: @6800,
                                        GCDWebServerOption_BindToLocalhost: @YES,GCDWebServerOption_AutomaticallySuspendInBackground: @YES
                                        } error:NULL];
    }
    
    return _server.isRunning;
}

改为

- (BOOL)start{
    if (!_server.isRunning) {
       [self.server startWithPort:6800 bonjourName:nil];
    }    
    return _server.isRunning;
}

测试是可以正确设置端口修复Bug.

@zhongwuzw
Copy link
Owner

@CXTretar 你好,这个bug是必现的么?请提供iOS版本、设备等,我定位一下。

@zhongwuzw zhongwuzw added the bug? label Jun 14, 2018
@CXTretar
Copy link
Author

@zhongwuzw 应该是必现的,因为我自己的项目中使用同样的方式start,也出现问题,我重新下载master测试确定一下,测试用的模拟器iPhone 6 iOS 11.2. 真机 iPhone 5s iOS 10.2 。

@zhongwuzw
Copy link
Owner

@CXTretar ,我这边没法复现,根据你提供的URL,端口号显示为0,也就是_options赋值的时候6800没赋值上,你这边能在这打个断点调试一下么?

// GCDWebServer.m
- (BOOL)_start:(NSError**)error {
  GWS_DCHECK(_source4 == NULL);

  NSUInteger port = [_GetOption(_options, GCDWebServerOption_Port, @0) unsignedIntegerValue];

@CXTretar
Copy link
Author

@zhongwuzw 重新下载新的项目运行是没有问题的,但是早上我测试了很多遍一直有这个问题,这个会跟网络环境有关系?

@CXTretar
Copy link
Author

CXTretar commented Jun 14, 2018

image
这个错误是怎么造成的

@CXTretar
Copy link
Author

无法重现了,应该是模拟器出的异常。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants