标签: http-error

webrequest标头的顺序重要吗?

我正在发出POST请求,将图片上传到网站。
在页面中,有一个FileUpload和一个input (textBox),在fiddler中,我发现页面正在使用“多部分发布”请求模式发送一些数据,(Content Disposition: multipart-formdata;)
一切似乎都不错,因为在fiddler中,关于我的应用程序发布的内容和页面的内容都是相同的正在发送...只是关于标题顺序...

我的问题是,以正确的顺序放置标题真的很重要吗?如果可以,我该怎么办?(因为我们只是在请求中设置一些属性,所以没有地方可以设置顺序...)

感谢您的任何建议...

http-post httpwebrequest http-error http-request

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

如何显示自定义errorPage并仍然返回404

有一个包含的路由表

 routes.MapRoute("404-PageNotFound", "{*url}", new { controller = "Error", action = "PageNotFound" });
Run Code Online (Sandbox Code Playgroud)

web.config有:

<customErrors mode="RemoteOnly">        
   <error statusCode="404" redirect="/Error/PageNotFound" />
</customErrors>
Run Code Online (Sandbox Code Playgroud)

当没有路由匹配并且使用以下方式呈现错误视图时,ErrorController会被命中:

public ActionResult PageNotFound(ViewModelBase model)
 {
     return View(model);
}
Run Code Online (Sandbox Code Playgroud)

响应的状态代码为200,但在这种情况下需要404.有没有办法返回http代码404和客户错误?

asp.net-mvc http-error asp.net-mvc-4

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

输入无效的ID后应返回什么HTTP状态代码?

请求删除不存在的对象时应返回什么状态码?

public ContentResult DeleteEntity(int id, FormCollection FormData)
{
    Database db = new Database();
    TargetEntity te = db.TargetEntities.SingleOrDefault(t => t.Id == id);
    if(te == null)
    {
        Reponse.StatusCode = 400; //Is this correct?
        return Content("Deletion failed. Invalid ID: " + id);
    }
    //Delete the entity
    return Content("Successfully Deleted");
}
Run Code Online (Sandbox Code Playgroud)

该请求本身很好,只是发生了指定的ID无效(或该项目已被删除)的情况,因此我不确定400的范围。我敢肯定,这500个代码甚至不适合此代码,因为服务器上没有出错(只是要求删除不存在的内容)。

哪种状态码在这里最合适?

http http-error http-headers asp.net-mvc-2

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

使用 nginx 拦截上游错误

我的应用程序使用 nginx 和 uwsgi (python) 运行。我的目标是要断开连接(如解释在这里),例如,当Python应用程序决定这样做。

是否有一个 nginx 参数来“拦截”类似的上游错误proxy_intercept_errors

根据这个答案

我的 nginx 配置:

location / {
    uwsgi_pass                myapp;
    include                   uwsgi_params;

    uwsgi_buffering           on;
    uwsgi_buffer_size         8k;

    uwsgi_connect_timeout     800;

    uwsgi_read_timeout        800;
    uwsgi_send_timeout        800;

    proxy_intercept_errors  on;
    error_page 420 =444 @foo;
}

location @foo {
    return 444;
}
Run Code Online (Sandbox Code Playgroud)

我尝试了所有可能的组合,我可以想到有/没有proxy_intercept_errorserror_page但无论我如何配置 nginx,当我返回420 Enhance your calm(或任何其他错误代码,显然)时,它都会直接传递给客户端。

这个答案建议使用,proxy_next_upstream但这意味着使用proxy_pass而不是uwsgi_pass. 我需要使用,uwsgi_pass因为我需要将某些参数传递给 python 应用程序。

nginx http-error uwsgi

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

某些文件返回错误 520

我的网络服务器中的一些文件正在返回Error 520: Web server is returning an unknown error。据我所知,返回错误的文件是index.phpgoogle0f3d9b***.html(用于验证 Google 网站管理员控制台)。

以下是我的.htaccess文件:

RewriteBase /

# Force non-www version
RewriteCond %{HTTP_HOST} ^www\.yikjin\.ga [NC]
RewriteRule ^(.*)$ https://yikjin.ga/$1 [L,R=301]

# Prevent 000webhost ads from poping up
php_value auto_append_file none

# Prevent directory listing
Options -Indexes

# Make index.php default
DirectoryIndex index.php
Run Code Online (Sandbox Code Playgroud)

和我的index.php

<!DOCTYPE html>
<html>
<head>
    <!-- ... -->
</head>

<body>
<header>
    <img src="/drawable/images/me.jpg" width="6%" alt="That's us!" title="That's us!">
    <span>Welcome to Cards!</span>
</header> …
Run Code Online (Sandbox Code Playgroud)

php .htaccess http-error

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

来自 nginx 的 422 状态代码的响应缺少“Access-Control-Allow-Origin”标头

nginx配置如下:

server {
            listen 80;
            listen [::]:80;

            add_header 'Access-Control-Allow-Origin' $http_origin;
            add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, DELETE, PUT, PATCH';
            add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
            add_header 'Access-Control-Max-Age' 1728000;

            server_name erp.dev.thinkerx.com;
            access_log  /home/thinkerx/nginx/access.log;
            error_log /home/thinkerx/nginx/error.log;
            location ~ /.well-known {
                    allow all;
            }

            # The rest of your server block
            root /usr/share/nginx/html/men2017-back-dev/public;
            index index.html index.htm index.php;

            location /api/ {
                    try_files $uri $uri/ /index.php$is_args$args;
            }

            location ~ \.php$ {
                            try_files $uri /index.php =404;
                            fastcgi_pass 127.0.0.1:9000;
                            fastcgi_index index.php;
                            fastcgi_buffers 16 16k;
                            fastcgi_buffer_size 32k;
                            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                            include fastcgi_params; …
Run Code Online (Sandbox Code Playgroud)

nginx http-error cors

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

GCP 负载平衡器 502 服务器错误和“backend_connection_closed_before_data_sent_to_client”IIS 10

我有带有 4 个 IIS 10 Web 服务器的 GCP 负载平衡器。偶尔会出现502-Server error。在日志中它显示这是因为backend_connection_closed_before_data_sent_to_client。我已经通读了这篇文章https://cloud.google.com/compute/docs/load-balancing/http/,它说 nginx 和 apache 的 keepalive timout 需要设置为 620 秒。我如何在 IIS 10 中做同样的事情。

iis load-balancing http-error google-cloud-platform iis-10

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

urllib.error.HTTPError:HTTP 错误 403:从 pytorch hub 加载 resnet18 时超出速率限制

我不确定为什么会出现速率限制错误。

(fashcomp) [jalal@goku fashion-compatibility]$ python main.py --test --l2_embed --resume runs/nondisjoint_l2norm/model_best.pth.tar --datadir ../../../data/fashion
/scratch3/venv/fashcomp/lib/python3.8/site-packages/torchvision/transforms/transforms.py:310: UserWarning: The use of the transforms.Scale transform is deprecated, please use transforms.Resize instead.
  warnings.warn("The use of the transforms.Scale transform is deprecated, " +
Traceback (most recent call last):
  File "main.py", line 313, in <module>
    main()    
  File "main.py", line 105, in main
    model = torch.hub.load('pytorch/vision:v1.9.0', 'resnet18', pretrained=True)
  File "/scratch3/venv/fashcomp/lib/python3.8/site-packages/torch/hub.py", line 362, in load
    repo_or_dir = _get_cache_or_reload(repo_or_dir, force_reload, verbose)
  File "/scratch3/venv/fashcomp/lib/python3.8/site-packages/torch/hub.py", line 162, in _get_cache_or_reload
    _validate_not_a_forked_repo(repo_owner, repo_name, branch)
  File …
Run Code Online (Sandbox Code Playgroud)

python http-error torch pytorch

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

“指定的密钥字节数组是 192 位,对于任何 JWT HMAC-SHA 算法来说都不够安全......”mockmvc post 请求的错误

我想调用 write 下面的代码来编写 Kotlin 中登录的集成测试:

@Test
fun userSignup() {
    var result  = this.mockMvc.perform(post("http://localhost/signup")
        .content("{\"email\" : \"email\", " +
                "\"username\" : \"username\", " +
                "\"password\" : \"password\", " +
                "\"userType\" : \"artist\"}")
        .contentType(MediaType.APPLICATION_JSON)
        .header("Authorization", Base64() )
    )
        .andExpect(status().isOk())
        .andDo(MockMvcResultHandlers.print())
}
Run Code Online (Sandbox Code Playgroud)

但我收到 HTTP 状态 400,并显示错误消息:

“指定的密钥字节数组为 192 位,对于任何 JWT HMAC-SHA 算法来说都不够安全。JWT JWA 规范(RFC 7518,第 3.2 节)规定,与 HMAC-SHA 算法一起使用的密钥的大小必须 >= 256 位(密钥大小必须大于或等于哈希输出大小。)考虑使用 io.jsonwebtoken.security.Keys#secretKeyFor(SignatureAlgorithm) 方法来创建保证对您首选的 HMAC-SHA 算法足够安全的密钥。有关更多信息,请参阅https://tools.ietf.org/html/rfc7518#section-3.2 。”

我该如何解决这个错误?

我期待 Http 200 状态。此错误消息的级别太低,我在使用抽象库进行测试时不会看到它。

key rfc http-error hmac mockmvc

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

获取HTTP错误500.0

我的系统是Windows XP SP2,我的服务器是Microsoft Webmatrix.PHP运行良好,但是当我尝试添加数据库连接时,它会提供http错误500.0.发出错误的代码段

$db = new MySQLi('localhost', 'my_login', 'my_pass', 'db_name');
if ($db->connect_errno()) {
    printf("Connect failed: %s\n", $db->connect_error());
    exit();
}
Run Code Online (Sandbox Code Playgroud)

当我删除它时,页面加载正常.我该如何解决?

php mysql http-error

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

ResponseMode =“文件”不起作用

我想将简单的html页面添加为IIS的自定义错误。所以我添加404.html500.html页面进行项目并添加下一个配置:

<httpErrors errorMode="Custom" existingResponse="Replace">
    <remove statusCode="404" />
    <remove statusCode="500" />
    <error statusCode="404" path="404.html" responseMode="File" />
    <error statusCode="500" path="500.html" responseMode="File" />
</httpErrors>
Run Code Online (Sandbox Code Playgroud)

HTML页面位于Views/Shared文件夹中。但是每次我走到一条不存在的道路时,我都会/foo/bar收到The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.不是我的错误消息。

对于ASP.Net的自定义错误,我添加下一个配置:

<customErrors mode="On" redirectMode="ResponseRewrite" defaultRedirect="~/Home/404">
    <error statusCode="404" redirect="~/Home/404" />
    <error statusCode="500" redirect="~/Home/500" />
</customErrors>
Run Code Online (Sandbox Code Playgroud)

filters.Add(new HandleErrorAttribute());从FilterConfig文件中删除此行。

我发现html页面正确路径或更改/为的可能问题,\但没有人发现对我有用的解决方案。


我使用IIS7 +

asp.net iis asp.net-mvc http-error custom-error-pages

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