小编whi*_*ok6的帖子

使用Postman发送POST参数不起作用,但发送GET参数会起作用

我正在尝试使用Chrome扩展程序Postman测试一个简单的PHP页面.当我发送URL参数时,脚本工作正常(例如,变量在$_REQUEST参数中可用).当我将它们作为x-www-form-urlencoded参数发送时,该$_REQUEST参数仅包含PHPSESSID.

剧本:

<?php
var_export($_REQUEST);
?>
Run Code Online (Sandbox Code Playgroud)

当我发送URL参数时,$_REQUEST包括它们: 网址参数

但是当我将它们作为POST变量发送时,$_REQUEST不包括它们: 在此输入图像描述

我错过了什么?

php postman

68
推荐指数
6
解决办法
13万
查看次数

Dropwizard和SSL

我似乎无法配置Dropwizard使用ssl.

我创造了一把钥匙

openssl genrsa -des3 -out server.key 1024
Run Code Online (Sandbox Code Playgroud)

和证书

openssl req -new -key server.key -days 365 -out server.crt -x509
Run Code Online (Sandbox Code Playgroud)

并将其导入密钥库

keytool -import -file server.crt -keystore keystore.jks
Run Code Online (Sandbox Code Playgroud)

从那里开始,我将keystore.jks文件放在/ src/main/resources中,并放在了dropwizard的config.yaml文件旁边.

然后我尝试根据手册为dropwizard配置ssl:

http:
  ssl:
    keyStore: ./keystore.jks
    keyStorePassword: ********
Run Code Online (Sandbox Code Playgroud)

但是,当我导航到登录页面时,它只能在没有https的情况下工作:并且在使用https时会出现错误107(net :: ERR_SSL_PROTOCOL_ERROR):SSL协议错误.

还有其他我缺少的步骤吗?

ssl https configuration dropwizard

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

为什么我的 git pre-commit 钩子没有运行?

直到最近——我几天前才注意到这一点——我的 git pre-commit 钩子正在工作。我正在编写一个 React 应用程序,并在提交之前使用 Husky、TSLint 和 Prettier 来清理和整理我的代码。现在,当我更改和提交文件时,预提交钩子不会运行。

我的项目结构如下所示:

- project
  - .git/
  - react/   <- the frontend
    - node_modules/
    - src/
    - package.json
    - (other files)
  - nodejs/  <- the server
    - node_modules/
    - src/
    - package.json
    - (other files)
  - package.json
  - (other files)
Run Code Online (Sandbox Code Playgroud)

如果我手动执行钩子,它似乎运行良好:

[/project/react] # git status
On branch fixHusky
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

    modified:   MyFile.ts

[/project/react] # ../.git/hooks/pre-commit
husky > pre-commit (node v12.6.0)
  ? Stashing changes... …
Run Code Online (Sandbox Code Playgroud)

git husky

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

子类和get_shared_from_this()

我需要找到一个解决方案,允许子类获得正确的智能指针.

class Parent : public enable_shared_from_this {
  ...
}

class Child : public Parent {
  public Child(){
    boost::shared_ptr<Parent> pointer=shared_from_this(); // should work
    boost::shared_ptr<Child> pointer=shared_from_this(); // won't work.

  ...
}
Run Code Online (Sandbox Code Playgroud)

如何使用shared_from_this()获得正确的智能指针?

背景:

我正在写一些通知器/监听器的东西,有些类自然需要从通知器注册和取消注册.例如,

class Body : extends Listener<BodyMessage>{ // listen for BodyMessage messages
  public:
    Body() {
      Notifier<BodyMessage>::register(this); // register with the appropriate notifier
    }

    virtual ~Body {
      Notifier<BodyMessage>::unregister(this); // unregister
    }

    bool notify(BodyMessage m){ ... }

  ...
}
Run Code Online (Sandbox Code Playgroud)

通常我会使用这个指针,一切都会好的.我已经让Notifier使用模板,因此我只能将消息传递给想要听到它们的消息.

但是,我想使用智能指针.如果通知程序如下所示:

template<typename t>
class Notifier {
  public:
    static void register<boost::shared_ptr<Listener<t>>> …
Run Code Online (Sandbox Code Playgroud)

c++ inheritance boost subclass shared-ptr

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

如何在hbase shell中指定包含选项卡的行键?

在我们无限的智慧中,我们决定用中间的标签键入我们的行:

item_id <tab> location
Run Code Online (Sandbox Code Playgroud)

例如:

000001  http://www.url.com/page
Run Code Online (Sandbox Code Playgroud)

使用Hbase Shell,我们无法执行get命令,因为选项卡字符无法在输入行中正确写入.我们尝试了

get 'tableName', '000001\thttp://www.url.com/page'
Run Code Online (Sandbox Code Playgroud)

没有成功.我们应该做什么?

shell hbase escaping

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

如何通过匹配值从另一个表插入表中?

我正在构建一个简单的库应用程序.我有一张叫做书的桌子; 其中的列是:

books:
book_id   | integer | not null default nextval('books_book_id_seq'::regclass)
title     | text    | not null
author    | text    | not null default 'unknown'::text
Run Code Online (Sandbox Code Playgroud)

我没有计划与作者做任何特别的事情,因为我关心他们的都是他们的名字(所以没有连接表,没有作者表等等).但是,我发现用作查找书籍的API端点将是需要某种作者ID:

/browse/author/12345
Run Code Online (Sandbox Code Playgroud)

代替

/browse/author/Arthur%20C%20Clarke (or whatever)
Run Code Online (Sandbox Code Playgroud)

我为作者创建了一个单独的表:

authors:
author_id   | integer | not null default nextval('authors_author_id_seq'::regclass)
author_name | text    | not null
Run Code Online (Sandbox Code Playgroud)

并需要通过id列将每个书行引用给作者.我知道我需要一个外键,但由于书籍表中没有数据我不能简单地打一个(所有空值等),无论如何我仍然需要获取所有作者id并将它们插入到正确的行.

如何根据匹配现有列中的值将正确的author_ids插入books表?我试过了:

insert into books (author_id) select author_id from authors where (books.author == authors.author_name);
Run Code Online (Sandbox Code Playgroud)

但可以预见的是,这太天真了.

sql postgresql sql-update

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

Jquery cookie未检测到不存在

当给定的cookie不存在时,结果必须为null未定义,但在这种情况下,favouritescook不存在,但脚本认为它确实存在.

对于null或undefined,结果必须为"OK Detect",但结果为"BAD no detect result".为什么这不起作用?

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.js"></script>
<script>
actcookies=jQuery.cookie("favouritescook");
function fav(id)
{
    if (actcookies=='undefined' || actcookies=='null')
    {
        alert("OK detect");
    }
    else
    {
        alert("BAD Not detect Result : "+actcookies);
    }
}
</script>

<div onclick="fav(1);">Test Now 1</div>
Run Code Online (Sandbox Code Playgroud)

我在不同的浏览器中试过这个,结果相同.我不明白这一点.

javascript cookies jquery

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

在 phpunit.xml 中将进程隔离设置为 false 会导致 Laravel 功能测试失败

在我们之前的应用程序中,使用 Laravel 5.3,设置processIsolation为 false 可以加快我们的测试速度,而不会导致任何错误:

phpunit.xml:
<phpunit backupGlobals="false"
     ...
     processIsolation="false"
     stopOnFailure="false">
Run Code Online (Sandbox Code Playgroud)

在我们当前的项目中,在 laravel 5.4 中,设置processIsolation为 false 会导致我们所有的功能测试失败(尽管它们确实更快)(为了简洁起见,删除了一些测试):

5) Tests\Feature\CallsToActionApiControllerTest::testUsers
Symfony\Component\HttpKernel\Exception\NotFoundHttpException:
/johnny/vendor/laravel/framework/src/Illuminate/Routing/RouteCollection.php:161
/johnny/vendor/laravel/framework/src/Illuminate/Routing/Router.php:533
/johnny/vendor/laravel/framework/src/Illuminate/Routing/Router.php:512
/johnny/vendor/laravel/framework/src/Illuminate/Routing/Router.php:498
/johnny/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:174
/johnny/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:30
/johnny/vendor/barryvdh/laravel-cors/src/HandleCors.php:34
/johnny/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:148
...
/johnny/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:102
/johnny/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:149
/johnny/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:116
/johnny/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php:234
/johnny/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php:206
/johnny/tests/Functional/CallsToAction/CallsToActionApiControllerTest.php:142

...
7) Tests\Feature\EmailEndpointControllerTest::testCaptureEventsWithBlankRequest
Expected status code 200 but received 404.
Failed asserting that false is true.

/johnny/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestResponse.php:55
/johnny/tests/Functional/Email/EmailActionApiControllerTest.php:88

8) Tests\Feature\EmailEndpointControllerTest::testUnsubscribe
Expected status code 200 but received 404.
Failed asserting that false is true.

/johnny/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestResponse.php:55
/johnny/tests/Functional/Email/EmailActionApiControllerTest.php:96

9) Tests\Feature\EmailEndpointControllerTest::testUnsubscribeWithAlreadyUnsubscribedEmail
Expected status code 200 …
Run Code Online (Sandbox Code Playgroud)

php phpunit laravel-5.4

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

使用AWS javascript SDK V3,是否有等效的凭证提供程序链?

我正在使用 NodeJS 将适用于 AWS 的 javascript SDK 从 V2 迁移到 V3。我们的应用程序需要在几个地方检查凭据。之前我们使用了凭证提供程序链,但我在 V3 中找不到等效项。当我的脚本在本地运行时,我需要查看共享 INI 文件 ( SharedIniFileCredential),但该脚本也在 kubernetes 中运行,所以(我认为)我还需要roleAssumerWithWebIdentity. 如何在 V3 中使用凭证链?

javascript amazon-web-services aws-sdk-js

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

无法编译 Typescript:s3client 上不存在发送属性

我在 typescript/nodejs 环境中使用适用于 javascript 的 AWS SDK v3,但是当我使用 ts-node 运行它时,它抱怨无法在 s3client 上找到发送函数。我的代码:

\n
const client = new S3Client({\n  credentialDefaultProvider: this.getCredentialDefaultProvider\n  region: "us-west-2",\n});\nconst command = new ListObjectsCommand({\n  Bucket: bucket,\n  Prefix: prefix,\n});\nconst result = await client.send(command);\n
Run Code Online (Sandbox Code Playgroud)\n

启动服务器时出现的错误是这样的:

\n
/server/node_modules/ts-node/src/index.ts:230\n  return new TSError(diagnosticText, diagnosticCodes)\n\nTSError: \xe2\xa8\xaf Unable to compile TypeScript:\nsrc/controllers/aws.controller.ts(56,37): error TS2339: Property \'send\' does not exist on type \'S3Client\'.\n
Run Code Online (Sandbox Code Playgroud)\n

这与官方文档中的代码示例基本相同。但我已经安装了正确的包(甚至清除了我的node_modules文件夹并重新安装了它)并且node_modules中的代码看起来是正确的。我究竟做错了什么?

\n

对于上下文,这是一个在 docker-compose 容器中的 ts-node 中运行的 nodeJS 脚本。其他代码工作正常,包括使用相同客户端对象获取签名 URL 的命令。

\n

javascript node.js aws-sdk-js

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