标签: request-uri

为什么"没有找到与请求URI匹配的HTTP资源"?

我的控制器中有代码,如下所示:

[Route("api/deliveryitems/InsertIntoPPTData/{stringifiedRecord}")]
Run Code Online (Sandbox Code Playgroud)

......我正在通过Postman这样称呼它:

    http://localhost:21609/api/deliveryitems/InsertIntoPPTData?
stringifiedRecord=serNum77;tx2;siteNum2;bla2.xml;ppt_user2;tx_memo2;file_beg2;file_end2
Run Code Online (Sandbox Code Playgroud)

......但得到:

{
Message: "No HTTP resource was found that matches the request URI     
'http://localhost:21609/api/deliveryitems/InsertIntoPPTData?   stringifiedRecord=serNum77;tx2;siteNum2;bla2.xml;ppt_user2;tx_memo2;file_beg2;file_end2'."
MessageDetail: "No type was found that matches the controller named 'deliveryitems'."
}
Run Code Online (Sandbox Code Playgroud)

以相同方式创建和调用的其他REST方法也很好 - 为什么不是这个?与其他人没有共同点的唯一事情是它是一个HttpPost,而其他的是HttpGet.这有什么不同吗?我正在从邮差下拉试图调用此方法REST时选择"邮报".

UPDATE

是的,它显然与它是一个Post并在URI中传递args无关,因为我现在使用HttpGet方法获得相同的东西:

{
Message: "No HTTP resource was found that matches the request URI     
'http://localhost:21609/api/department/getndeptsfromid?firstId=2&countToFetch=12'."
MessageDetail: "No action was found on the controller 'Department' that matches the request."
}
Run Code Online (Sandbox Code Playgroud)

我从邮递员这样称呼它:

http://localhost:21609/api/department/getndeptsfromid?firstId=2&countToFetch=12
Run Code Online (Sandbox Code Playgroud)

......它确实出现在我的控制器中:

[HttpGet]
[Route("api/department/getndeptsfromid/{firstId}/{countToFetch}")]
public List<Department> GetNDepartmentsFromID(int FirstId, int CountToFetch)
{
    return CCRService.GetNDepartmentsFromID(FirstId, …
Run Code Online (Sandbox Code Playgroud)

c# controller http-post-vars request-uri postman

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

filter_input()$ _SERVER ["REQUEST_URI"],带有FILTER_SANITIZE_URL

我正在过滤$ _SERVER ["REQUEST_URI"],以便:

$_request_uri = filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_URL);
Run Code Online (Sandbox Code Playgroud)

正如php.net中所解释的:

FILTER_SANITIZE_URL

删除除字母,数字和$ -_之外的所有字符.+!*'(),{} |\^〜[]`<>#%"; /?:@&=.

然而,

浏览器发送此REQUEST_URI值urlencode'd,因此在此filter_input()函数中未对其进行清理.说地址是

http://www.example.com/abc/index.php?q=abc 123

然后是已清理的请求网址

/abc/index.php?q=abc%EF%BF%BD%EF%BF%BD123

但它应该是

/abc/index.php?q=abc123

有可能urldecode($ _ SERVER ["REQUEST_URI"])然后使用filter_var()我们可以获得一个已清理的值.

$_request_uri = filter_var(urldecode($_SERVER['REQUEST_URI']), FILTER_SANITIZE_URL);
Run Code Online (Sandbox Code Playgroud)

我不知道为什么最后一个在我看来"不优雅"而且我正在寻找一种优雅的方式,消毒$ _SERVER ["REQUEST_URI"].

也许,在编码时直接访问超级全局数组($ _SERVER ['REQUEST_URI'])会让我感到不安,因此"不优雅".

有优雅的方式吗?

php filtering global-variables input-sanitization request-uri

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

PHP:更改 URL 参数

这就是我所拥有的

echo '<button><a href="'.$_SERVER['REQUEST_URI'].'&startrow='.($startrow+100).'">Next 100</a></button>';
Run Code Online (Sandbox Code Playgroud)

我的网址中有 2 个参数,第一个是营销活动,第二个是 startrow,如何从网址中删除“startrow”参数及其值。我想要这样的东西。

echo '<button><a href="'.REMOVE &startrow=x($_SERVER['REQUEST_URI']).'&startrow='.($startrow+100).'">Next 100</a></button>';
Run Code Online (Sandbox Code Playgroud)

当我按下下一个 100 按钮时,页面会重新加载,并在 url 中添加 startrow 参数,因此如果我按下一个 100 按钮 5 次,则 url 中有 5 个 startrow 参数,所以我想先删除之前的 startrow 参数,然后添加新的那一个

我的实际网址: enquirytable.php/campaign=all&startrow=100

当我单击 Next 100 按钮时: enquirytable.php/campaign=all&startrow=100&startrow=200

我想要什么: enquirytable.php/campaign=all&startrow=200

php request-uri

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

收到 InvalidClientIdError (invalid_request) 重定向 URI 不匹配。使用 requests_oauthlib

我正在尝试使用库requests_oauthlib模拟消费者和提供者(server_to_server)之间的令牌交换。在提供商端授权后收到代码并将代码交换为令牌后,我收到错误。

所以我在回调函数中获取了代码,但它说重定向 uri 不匹配。我已经在提供商的数据库中检查了重定向 uri。他们是一样的。(作为下面代码中的变量redirect_uri)

查看我的 Django 实现:

视图.py

# create session
from importlib import import_module
SessionStore = import_module(settings.SESSION_ENGINE).SessionStore
session = SessionStore()

client_id = "123456"
client_secret = "123456"
authorization_base_url = 'http://localhost:8000/o/authorize/'
token_url = 'http://localhost:8000/o/token/'

redirect_uri = 'http://localhost:8888/callback'

# ONLY FOR A LOCALHOST
import os
os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = '1'


def index(request):
    provider = OAuth2Session(client_id, redirect_uri=redirect_uri)
    authorization_url, state = provider .authorization_url(authorization_base_url)

    # state is used to prevent CSRF, keep this for later.
    session['oauth_state'] = state
    # redirect to provider    
    return redirect(authorization_url)

def …
Run Code Online (Sandbox Code Playgroud)

django mismatch oauth-2.0 python-requests request-uri

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

Ubuntu 16.04 - Apache 2.4.18 - 请求 URI 太长

我正在尝试从 Google 图片搜索结果中保存图片,但是当我在查询字符串参数中发送图片的 src 时,会出现以下错误:

Request-URI Too Long 
The requested URL's length exceeds the capacity limit for this server.

Apache/2.4.18 (Ubuntu) Server at 127.0.1.1 Port 80
Run Code Online (Sandbox Code Playgroud)

当我在我的本地机器上遇到这个错误时,我可以测试你们所有的想法。

注:我没设置LimitRequestLineLimitRequestFieldSize100000/etc/apache2/apache2.conf文件。但到目前为止没有运气。

任何帮助表示赞赏。

apache ubuntu limit zend-framework2 request-uri

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

在iframe html标记内使用php

我正在尝试创建一个在iframe中显示另一个网站的网站。

这是我的代码:

<html> 
<title>HTML with PHP</title>
<style>
body {
margin: 0px;
}
</style>
<body>
<?php
$page = $_GET['query'];
echo $page;
?>
<iframe align="center" width="100%" height="100%" src="<?=$page;?>" frameborder="yes" scrolling="yes" name="myIframe" id="myIframe"> </iframe>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

当我从网站上打开php文件(使用url website.com/file.php?query= https://www.google.com)并查看检查器时,可以看到iframe加载的页面,但它只是显示为空白页,而不是。我在 http://www.test.fire-light.tk/web.php?query=url(用任何有效的URL替换URL)上显示。不知道为什么它显示空白页。

html php iframe request-uri

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