小编Kof*_*Kof的帖子

iOS 9上的NSURLConnection不使用HTTP/2协议

我在Jetty 9.3服务器上配置了HTTP/2,它有一个有效的证书和SSLLabs.com给它一个A级安全配置.

使用Chrome浏览到https://example.com加载正确的响应,它还报告使用了"h2"(HTTP/2")协议.

但是当尝试使用iOS 9访问相同的URL时NSURLConnection,我可以在请求日志中看到它使用的是HTTP 1.1.如果我在我的服务器上禁用HTTP 1.1,请求将在iOS 9上失败(但仍然在Chrome上成功).

NSURLConnection代码 -

let url = NSURL(string: "https://example.com")
request = NSURLRequest(URL: url, cachePolicy: NSURLRequestCachePolicy.ReloadIgnoringLocalCacheData, timeoutInterval: 10)

connection = NSURLConnection(request: request, delegate: self, startImmediately: true)
Run Code Online (Sandbox Code Playgroud)

服务器的ALPN调试输出 -

[S] ALPN protocols [spdy/3.1, spdy/3, http/1.1] received from client for 1e5e2487[SSLEngine[hostname=3.4.5.6 port=52090] SSL_NULL_WITH_NULL_NULL]
[S] ALPN protocol 'http/1.1' selected for 1e5e2487[SSLEngine[hostname=3.4.5.6 port=52090] SSL_NULL_WITH_NULL_NULL]
Run Code Online (Sandbox Code Playgroud)

在WWDC 2015中,有人表示iOS 9中的NSURLRequest支持HTTP/2,但客户端应用程序声称支持spdy/3.1, spdy/3, http/1.1,没有http/2.没有NSAppTransportSecurity例外设置.

我尝试在运行应用程序的同一个iPhone模拟器上使用Safari连接到服务器,这次它工作并使用HTTP/2,这里是ALPN调试输出 -

[S] ALPN protocols [h2, h2-16, h2-15, h2-14, spdy/3.1, …
Run Code Online (Sandbox Code Playgroud)

nsurlconnection nsurlrequest ios http2 ios9

6
推荐指数
1
解决办法
4322
查看次数

Bash脚本/命令从文件名中批量删除"@ 2x"(视网膜图像 - >正常)

如何在bash命令或脚本中重命名大量文件,以删除iOS的视网膜指示器(@ 2x)?

我已经调整了它们的大小,但重命名软件在重命名输出文件时并不聪明.

bash rename bulk mv

5
推荐指数
1
解决办法
947
查看次数

当返回到已停止的活动时,碎片会因旧数据而膨胀

活动 A 有片段。当它启动对活动 B 的意图时B.finish(),然后当 时,AonCreate()再次执行。

但这一次,即使A.onCreate()有 newPacksPagerAdapter和 new ViewPager,片段也显示为旧数据。

我可以看到它onCreateView()为每个片段执行,但由于static newInstance()没有调用它,它仍然具有旧参数。getItem(position)调用FragmentPagerAdapter 时会创建参数。

这是它的实施方式 -

public class PackActivity extends Activity {
    ...
    PacksPagerAdapter mPacksPagerAdapter;
    ViewPager mViewPager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mPacksPagerAdapter = new MyPagerAdapter(getFragmentManager());

        // Set up the ViewPager with the sections adapter.
        mViewPager = (ViewPager) findViewById(R.id.pager);
        mViewPager.setAdapter(mPacksPagerAdapter);
        mViewPager.setOffscreenPageLimit(PACK_PAGES - 1);

        mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
                    @Override
                    public void onPageSelected(int position) {
                        actionBar.setTitle(...);
                    } …
Run Code Online (Sandbox Code Playgroud)

android android-fragments android-viewpager android-activity android-pageradapter

5
推荐指数
1
解决办法
2900
查看次数

当方向设置为水平时,UIPageViewController响应垂直平移

我已经烧了几个小时.我已经初始化UIPageViewControllerUIPageViewControllerNavigationOrientationHorizontal,但由于某种原因viewControllerBeforeViewController被称为当用户锅垂直.

此外,当发生这种情况时,没有页面翻转,didFinishAnimating:didFinishAnimating:previousViewControllers:transitionCompleted根本不会被调用.这意味着页面视图控制器知道这是一个垂直运动..

这是初始化代码 -

- (void)initPageViewController
{
    self.pageViewController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStylePageCurl
                                                              navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal 
                                                                            options:nil];
    self.pageViewController.delegate = self;
    self.pageViewController.dataSource = self;

    [self addChildViewController:self.pageViewController];
    [self.view addSubview:self.pageViewController.view];

    // Set the page view controller's bounds using an inset rect so that self's view is visible around the edges of the pages.
    self.pageViewController.view.frame = self.view.bounds;

    [self.pageViewController didMoveToParentViewController:self];

    // Leave only pan recognizers enabled, so buttons positioned inside a page would work.
    for (UIGestureRecognizer *gr in self.pageViewController.gestureRecognizers)
    { …
Run Code Online (Sandbox Code Playgroud)

uipageviewcontroller

4
推荐指数
1
解决办法
1567
查看次数

Gradle使用servlet-api 2.5而不是3.0.1创建war

我正在使用Gradle 1.9(下面的额外详细信息)来构建一个将在Jetty 9(jetty-9.0.5.v20130815)上运行的WAR.

它配置为web.xml-

<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:fmt="http://java.sun.com/jsp/jstl/fmt"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
...
Run Code Online (Sandbox Code Playgroud)

build.gradle有这种依赖 -

repositories {
    mavenCentral()
}
dependencies {
    providedCompile 'javax.servlet:javax.servlet-api:3.0.1'
    compile 'org.springframework:spring-webmvc:3.2.2.RELEASE'
    compile 'javax.mail:mail:1.4.7'
    compile 'org.codehaus.jackson:jackson-mapper-asl:1.9.13'
    compile 'org.apache.directory.studio:org.apache.commons.io:2.4'
    compile 'commons-net:commons-net:3.3'
    compile 'mysql:mysql-connector-java:5.1.26'
    compile 'org.springframework:spring-jdbc:3.2.4.RELEASE'
    compile 'commons-fileupload:commons-fileupload:1.3'
    compile 'commons-pool:commons-pool:1.6'
    compile 'commons-dbcp:commons-dbcp:1.4'
    compile 'log4j:log4j:1.2.17'
    compile 'org.slf4j:slf4j-api:1.7.5'
    compile 'org.slf4j:slf4j-log4j12:1.7.5'
    runtime 'javax.servlet:jstl:1.1.2'
}
Run Code Online (Sandbox Code Playgroud)

building using使用in gradle clean war生成一个WAR文件.servlet-api-2.5.jarWEB-INF/lib/

更多环境细节 -

Build time:   2013-11-19 08:20:02 UTC
Build number: none
Revision:     7970ec3503b4f5767ee1c1c69f8b4186c4763e3d

Groovy:       1.8.6
Ant:          Apache Ant(TM) version …
Run Code Online (Sandbox Code Playgroud)

java jetty war gradle

4
推荐指数
2
解决办法
1万
查看次数

在 node.js 中运行 sqlite3 查询返回 `undefined` 行,没有错误

使用Node.js 4.2.1sqlite3 3.1.1下面的代码-

var sqlitedb = new sqlite3.Database(sqliteFilename);
sqlitedb.serialize(function() {

   sqlitedb.run("SELECT ZDATA FROM ZMYTABLE;", function(err, rows) {
      console.log(rows);
   });

});
sqlitedb.close();
Run Code Online (Sandbox Code Playgroud)

undefined在控制台中打印,但如果使用该sqlite3工具执行相同的查询,它工作正常 -

$ sqlite3 backup.sqlite 
SQLite version 3.8.10.2 2015-05-20 18:17:19
Enter ".help" for usage hints.
sqlite> SELECT ZDATA FROM ZMYTABLE;
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
...
Run Code Online (Sandbox Code Playgroud)

知道为什么 SQL 会undefined在 Node.js 中返回行吗?

sqlite node.js

3
推荐指数
1
解决办法
3848
查看次数

发送 APN 返回 BadDeviceToken,DeviceToken 格式应该是什么?

我的后端使用 Node.js 和 Express.js,使用该包处理 APN npm apn,该包使用 Apple 的新提供商身份验证令牌。iOS应用程序获得许可并将收到的32字节设备令牌发送到后端,编码为base64字符串。

但是,当尝试使用设备令牌(编码为 ascii、utf8 或 base64)发送推送通知时,APN 服务器返回 -

{"sent":[],"failed":[{"device":"....token....","status":"400","response":{"reason":"BadDeviceToken"}}]}
Run Code Online (Sandbox Code Playgroud)

发送到 APN 服务器时令牌的格式应该是什么?

apn node.js ios

3
推荐指数
1
解决办法
9866
查看次数

请求Content-Type为gzip时,Jetty会响应400 Bad Request

Java 1.8.0_45-b14运行的Spring MVC 后端在Jetty 9.3.0.v20150612未压缩的请求中运行良好,但无法接受压缩的请求.

我在这里遵循了Gzip Handler配置说明,确保这些POST请求也受支持.虽然它没有说这种配置完全适用于请求......但它可能仅用于响应.

etc/jetty-gzip.xml -

<Configure id="Server" class="org.eclipse.jetty.server.Server">
  <Get id="next" name="handler" />
  <Set name="handler">
    <New id="GzipHandler" class="org.eclipse.jetty.server.handler.gzip.GzipHandler">
      <Set name="handler"><Ref refid="next" /></Set>
      <Set name="minGzipSize"><Property name="jetty.gzip.minGzipSize" deprecated="gzip.minGzipSize" default="2048"/></Set>
      <Set name="checkGzExists"><Property name="jetty.gzip.checkGzExists" deprecated="gzip.checkGzExists" default="false"/></Set>
      <Set name="compressionLevel"><Property name="jetty.gzip.compressionLevel" deprecated="gzip.compressionLevel" default="-1"/></Set>
      <Set name="excludedAgentPatterns">
        <Array type="String">
          <Item><Property name="jetty.gzip.excludedUserAgent" deprecated="gzip.excludedUserAgent" default=".*MSIE.6\.0.*"/></Item>
        </Array>
      </Set>

      <Set name="includedMethods">
        <Array type="String">
            <Item>GET</Item>
            <Item>POST</Item>
        </Array>
      </Set>

      <Set name="includedPaths">
        <Array type="String">
          <Item>/*</Item>
        </Array>
      </Set>

    </New>
  </Set>
</Configure>
Run Code Online (Sandbox Code Playgroud)

在web.xml中 -

<filter>
    <filter-name>GzipFilter</filter-name>
    <filter-class>org.eclipse.jetty.servlets.GzipFilter</filter-class> …
Run Code Online (Sandbox Code Playgroud)

java http jetty spring-mvc

1
推荐指数
1
解决办法
1629
查看次数