小编Sim*_*gro的帖子

PWA 最小服务人员只是为了触发安装按钮?

用于触发安装按钮的最小服务人员是什么?

我不想缓存任何内容,并且该应用程序无法在离线模式下工作,但我希望允许用户在桌面上创建快捷方式。

javascript service-worker progressive-web-apps

21
推荐指数
2
解决办法
2680
查看次数

PHP SoapClient:SoapFault异常无法连接到主机

使用此代码我发出肥皂请求

$client = new SoapClient('http://example.com/soap/wsdl');

try {
    $result = $client->myMethod();
} catch (Exception $e) {
    echo $e->getMessage();
}
Run Code Online (Sandbox Code Playgroud)

有时(十分之一)会引发异常:

SoapFault异常:[HTTP]无法连接到主机

我的尝试

1)我寻找解决方案,我读到这个问题可能是由wsdl缓存引起的,我将其禁用php.ini:

soap.wsdl_cache_enabled = 0
soap.wsdl_cache_ttl = 0
Run Code Online (Sandbox Code Playgroud)

提出更少的例外

2)我试图添加到Windows的主机(它们在Windows上)dns的分辨率windows/system32/drivers/etc/hosts:

160.XX.XXX.XX example.com
Run Code Online (Sandbox Code Playgroud)

提出更少的例外

3)我还尝试禁用"Windows防火墙",

提出更少的例外

4)我还尝试在php.ini中增加default_socket_timeout

default_socket_timeout = 90
Run Code Online (Sandbox Code Playgroud)

什么也没有变

这个问题

服务器肥皂似乎没有问题.它也可以从其他网站使用没有问题.还有什么我可以做的吗?

我的设置

PHP 5.6

Apache 2.4

Windows Server 2012

UPDATE

经过多次测试,我认为问题出在网络上,肥皂服务器背后是反向代理,问题出现在代理中.

php soap soap-client soapserver

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

如何删除树枝中的第一个数组项?

我在树枝上有一个名为'Posts'的数组.

有没有办法轻松删除此数组的第一项?

所以它的结构是这样的:

array('post 1','post 2','post 3')
Run Code Online (Sandbox Code Playgroud)

而且我想知道是否可以使用twig中的函数轻松删除第一个帖子:

array('post 2','post 3')
Run Code Online (Sandbox Code Playgroud)

twig

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

Angular 测试无法在 Travis 上运行,并出现错误“发现 1 个加载错误”

为什么我的 travis conf 无法执行 Angular 测试?

.travis.yml

language: node_js
node_js:
  - "16"

addons:
  chrome: stable

cache:
  directories:
    - ./node_modules
    - ./.angular

install:
  - npm install

script:
  - npm run test -- --code-coverage --no-watch --no-progress --browsers=ChromeHeadlessCI

after_script:
  - cat ./coverage/*/lcov.info | ./node_modules/coveralls/bin/coveralls.js
Run Code Online (Sandbox Code Playgroud)

错误

错误 [karma-server]:[39mError:在服务器上发现 1 个加载错误。(/home/travis/build/node_modules/karma/lib/server.js:239:26) 在 Object.onceWrapper (node:events:509:28) 在 Server.emit (node:events:402:35) 在服务器.emit(节点:域:475:12)在emitListeningNT(节点:net:1368:10)在processTicksAndRejections(节点:内部/进程/task_queues:82:21)

完整日志

> ng test "ng-simple-state" "--code-coverage" "--no-watch" "--no-progress" "--browsers=ChromeHeadlessCI"

[91m13 11 2021 19:17:19.850:ERROR [reporter]: [39mCan not load reporter "coverage", it is not registered!
  Perhaps you are missing …
Run Code Online (Sandbox Code Playgroud)

travis-ci karma-runner karma-jasmine angular

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

PHP/Javascript分块上传:如果filesize超过upload_max_filesize或post_max_size,则IE9损坏文件

我正在使用Plupupload上传文件.如果我尝试加载exeIE9及其文件大小upload_max_filesizepost_max_size设置,则上传的文件已损坏.

这是我正在使用的PHP脚本:

<?php
/**
 * upload.php
 *
 * Copyright 2013, Moxiecode Systems AB
 * Released under GPL License.
 *
 * License: http://www.plupload.com/license
 * Contributing: http://www.plupload.com/contributing
 */

// Make sure file is not cached (as it happens for example on iOS devices)
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

// 5 minutes …
Run Code Online (Sandbox Code Playgroud)

javascript php chunked-encoding plupload

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

Delphi:TIdHTTP 与 TNetHTTPClient

我正在 Delphi 中编写一个下载管理器,其中包含一些自定义功能,例如可恢复下载和通过代理下载。

我正在研究不同的组件解决方案:Indy 和 NetHTTP,两者看起来非常接近。

  • TNetHTTPClient好像是 的接口winhttp.dll

  • TIdHTTP似乎是wininet.dll(但我不确定)的接口。

  • TIdHTTP 似乎是一个非常古老的组件(可能非常稳定/经过测试)并且有大量在线文档。

  • TNetHTTPClient 似乎是一个非常新的组件,并且没有很好的在线文档。

我有点犹豫……该选择哪一个?

关键是:这两个组件之间的主要区别什么?

我的问题有点有争议(主要基于意见),但我还没有找到这两个组件之间的任何实际比较。

delphi indy idhttp dotnet-httpclient

8
推荐指数
2
解决办法
5750
查看次数

Angular:在 JSON HttpRequest 和 HttpResponse 对象中序列化/反序列化

我想缓存到“ localstorage ”中的HttpRequestHttpResponse@angular/common/http

localstorage只接受string,所以我想序列化/反序列化与两个对象(的HttpRequest和HttpResponse对象)JSON.stringfy()JSON.parse()

问题是HttpRequest并且HttpResponse都是带有一些ES6 Map(例如HttpHeaders)和一些 getter/setter 函数的复杂类,JSON.stringfy()并且JSON.parse()序列化/反序列化不返回相同的对象并且一些信息丢失了。

有序列化/反序列化HttpRequestHttpResponse类的方法吗?

我正在寻找完整的序列化/反序列化(标头、参数、正文等)

在这个例子中,有两种方法用于序列化和反序列化 HttpRequest,例如:

function serializeRequest(angularRequest: HttpRequest): string {
  return null; // to implement
}
function unserializeRequest(jsonRequest: string): HttpRequest {
  return null; // to implement
}

// this is an example of request
const originalRequest = new HttpRequest('POST', 'https://angular.io/docs?foo=bar', {foo: true}, { …
Run Code Online (Sandbox Code Playgroud)

javascript typescript angular

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

没有数据库的PHP Symfony2自定义身份验证(SOAP)

我有一个肥皂来验证用户

<?php
$client = new SoapClient('http://mysite/code/soap.wsdl');
$user   = $client->login('username','password');

if( isset($user['IdAccount']) && ($user['IdAccount'] > 0) )
   echo 'Logon OK';
else
   echo 'Logon Fail!';
Run Code Online (Sandbox Code Playgroud)

我想在没有数据库的Symfony2中使用,只在内存中...

我尝试实现自定义UserProvider,但我没有使其工作所需的所有数据...

class WebserviceUserProvider implements UserProviderInterface
{
    public function loadUserByUsername($username)
    {
        $client = new SoapClient('http://mysite/code/soap.wsdl');

        $user   = $client->login($username, PASSWORD???? );

        if ( isset($user['IdAccount']) && ($user['IdAccount'] > 0) ) 
            return new WebserviceUser($username, PASSWORD????, SALT???, ROLES????);

        throw new UsernameNotFoundException(sprintf('Username "%s" does not exist.', $username)
    );
}
Run Code Online (Sandbox Code Playgroud)

我不能改变肥皂

对不起,我的英语不好!:(

php symfony

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

Angular 9:如何使用 HttpInterceptor 显示请求的堆栈跟踪?

我有一个HttpInterceptor,出于开发目的,我想打印发出请求的函数的堆栈跟踪:

import { Injectable } from '@angular/core';
import {
  HttpRequest,
  HttpHandler,
  HttpEvent,
  HttpInterceptor
} from '@angular/common/http';
import { Observable } from 'rxjs/Observable';

@Injectable()
export class HttpInterceptorService implements HttpInterceptor {

  intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
    console.log('Who has made this request?', new Error().stack);
    return next.handle(request);
  }
}
Run Code Online (Sandbox Code Playgroud)

控制台日志的输出为:

at HttpInterceptorService.intercept (:4200/main.js:1344) [angular]
    at HttpInterceptorHandler.handle (:4200/vendor.js:30718) [angular]
    at HttpXsrfInterceptor.intercept (:4200/vendor.js:31484) [angular]
    at HttpInterceptorHandler.handle (:4200/vendor.js:30718) [angular]
    at HttpInterceptingHandler.handle (:4200/vendor.js:31549) [angular]
    at MergeMapSubscriber.project (:4200/vendor.js:30457) [angular]
    at MergeMapSubscriber._tryNext (:4200/vendor.js:112207) [angular]
    at MergeMapSubscriber._next (:4200/vendor.js:112197) …
Run Code Online (Sandbox Code Playgroud)

javascript angular-http-interceptors angular

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

Angular HttpInterceptor 通过共享可观察对象来缓存并行请求

我想通过共享可观察对象来缓存 HTTP 并行请求,并将响应缓存在 Map 对象中。

在线演示

缓存interceptor.service.ts

import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest, HttpResponse } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable, of } from 'rxjs';
import { tap, finalize, share } from 'rxjs/operators';


@Injectable()
export class CachingInterceptorService implements HttpInterceptor {

  public readonly store = new Map<string, HttpResponse<any>>();
  public readonly queue = new Map<string, Observable<HttpEvent<any>>>();

  constructor() {}

  intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {

    // Don't cache if it's not cacheable
    if ( req.method !== 'GET' ) …
Run Code Online (Sandbox Code Playgroud)

javascript rxjs typescript angular

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