POST /重定向抛出一个'连接是reset`浏览器错误 [英] POST/Redirect throws a `Connection was reset` browser error

查看:274
本文介绍了POST /重定向抛出一个'连接是reset`浏览器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要建一个单页结帐为我们的客户。该结账应该包含各种形式的凭据,发货和付款。编辑previously输入的值也应该是可能的。这一切会罚款除了一件事。

我的页面是建立多个包括:

  • 证书
  • 在装运
  • 支付

在所有这些,包括我检查有关数据是在会话,如果它是我表现出不同的看法。这里没有什么特别。

例如:

 < PHP
如果(is_array($ _ SESSION ['凭据'])){
    ...显示填充值...
} 其他 {
    ......节目形式...
}
?>
 

当值已经设定,我也显示一个编辑按钮。我这样做如下:

 < D​​IV CLASS =左边栏>
    < H1类=称号左和步骤1  - 凭证< / H1>
    < D​​IV CLASS =拉左的风格=宽度:50%;>
        名称:姓名:LT; BR />
        地址:地址11< BR />
        邮政code:12345AA< BR />
        国家:国家< BR />
    < / DIV>

    < BR />
    < D​​IV的风格=明确:既;高度:10px的;>< / DIV>
    <中心>
        <形式方法=POSTACTION =/结算/凭证/>
            <输入类型=隐藏名称=编辑值=凭据>
            <按钮类=sexybutton sexysimple sexybestel>编辑< /按钮>
        < /形式GT;
    < /中心>
< / DIV>
 

其次是:

 < D​​IV CLASS =左边栏>
    < H1类=称号遗>第2步 - 装运< / H1>
    < I>选择运输方式和LT; / I>
    <形式方法=POSTACTION =/结算/支付/>
        <输入类型=无线电值=0NA​​ME =shipmentmethod>收集&LT​​; BR />
        <输入类型=无线电值=1NAME =shipmentmethod>交付< BR />
       <输入类型=提交值=转到第3步级=sexybutton sexysimple sexybestel右拉式NAME =出货>
    < /形式GT;
< / DIV>
 

在证书包括我检查了 $ _ POST ['编辑'] 。如果设置,我将再次与客户的previously填写数据输入字段显示的形式。

问题

每当我单击编辑按钮第一次,它将引发我一个连接被重置浏览器错误。如果我刷新页面,它会要求我再次提交表单。当我做这个错误消失。我似乎无法揣摩出这是来自。我检查了服务器日志,但没有什么不寻常的存在。

*注:* 发货和付款步骤之间会出现同样的问题。

有关的htaccess

 选项+了FollowSymLinks
RewriteEngine叙述上
的RewriteBase /

为了允许,拒绝
允许所有
的RewriteCond%{HTTP_HOST} ^ tapijttegelhandel \ .NL
重写规则^(。*)$ http://www.tapijttegelhandel.nl/$1 [R =永久,L]
AddDefaultCharset UTF-8

重写规则^结帐/ /index.php?mod=checkout&action=show [NC,L,QSA]
 

的index.php

 案结帐:
    $行动=使用isset($ _ GET ['行动'])? $ _GET [行动]:'';
    开关($行动){
        案完成:
            #...
            打破;

        情况下取消:
            #...
            打破;

        案凭据:
        案发货:
        案支付:
        情况下编辑:
        默认:
            包括$ _ SERVER ['DOCUMENT_ROOT']'结帐/ show.php。
            打破;
    }
    打破;
 

进度

  • 在我甩了会话变量,看看是否有东西在会议奇怪。 (任何异常)
  • 在我安装了一个篡改数据插件Firefox检查 POST 数据。 (任何异常或者)

更新

我发现了一些在我的code我检查一切,当最后一次跳过。这可能不过有些事情要与我的问题。

 <脚本类型=文/ JavaScript的>
         window.history.forward();
         功能noBack(){
              window.history.forward();
         }
    < / SCRIPT>
< /头>
<身体的onload =noBack(); onpageshow =如果(event.persisted)noBack(); onunload =>
 

工作流程

  /车优惠200 OK
/结帐/凭证/ GET 304 OK
/结帐/凭证/ POST 304 OK
# 编辑
/结帐/凭证/ POST  - 错误连接被重置
#刷新
/结帐/凭证/ POST 200 OK
 

解决方案

连接被重置

有时可以指一个PHP崩溃。在没有看到具体的文件,很难想,如果,为什么发生这种情况。

请一定要检查的error_log,类型:PHP --info | grep的错误,看看有什么文件,它被记录到(如果你是在Linux / UNIX)。

我的猜测是一只流浪突破;声明某处看到这个答案的一个可能的原因: http://stackoverflow.com/a/20036720/988324

您会发现这个在错误日志中的一些痕迹,但。如果您能提供这一点,我也许能帮助更多的。

I'm building a one-page checkout for a customer of ours. This checkout is supposed to contain all forms for credentials, shipment and payment. Editing previously entered values should also be possible. This is all going fine except for one thing.

My page is built of multiple includes:

  • credentials
  • shipment
  • payment

In each of these includes I check if the concerning data is in the session and if it is I show a different view. Nothing special here.

For example:

<?php
if (is_array($_SESSION['credentials'])) {
    ... show filled in values ...
} else {
    ... show form ...
}
?>

When values are already set, I also show an edit button. I do this as follows:

<div class="left-column">
    <h1 class="title-left">Step 1 - Credentials</h1>
    <div class="pull-left" style="width: 50%;">
        Name: name<br />
        Address: Address 11<br />
        Postal Code: 12345AA<br />
        Country: Country<br />
    </div>

    <br />
    <div style="clear: both;height: 10px;"></div>
    <center>
        <form method="POST" action="/checkout/credentials/">
            <input type="hidden" name="edit" value="credentials">
            <button class="sexybutton sexysimple sexybestel">Edit</button>
        </form>
    </center>
</div>

Followed by:

<div class="left-column">
    <h1 class="title-left">Step 2 - Shipment</h1>
    <i>Select a shipment method</i>
    <form method="POST" action="/checkout/payment/">
        <input type="radio" value="0" name="shipmentmethod"> Collect<br />
        <input type="radio" value="1" name="shipmentmethod"> Deliver<br />
       <input type="submit" value="Go to Step 3" class="sexybutton sexysimple sexybestel pull-right" name="shipment">
    </form>
</div>

In the credentials include I check for the $_POST['edit']. If it is set, i will show the form again with the customer's previously filled in data in the input fields.

The problem

Whenever I click the edit button the first time, it throws me a Connection was reset browser error. If I refresh the page, it will ask for me to submit the form again. When I do this the error is gone. I can't seem to figure out where this is coming from. I checked the server logs but there is nothing unusual there.

*Note: * The same problem occurs between the shipment and payment steps.

Relevant htaccess

Options       +FollowSymLinks
RewriteEngine On
RewriteBase /

order allow,deny
allow from all
RewriteCond %{HTTP_HOST} ^tapijttegelhandel\.nl
RewriteRule ^(.*)$ http://www.tapijttegelhandel.nl/$1 [R=permanent,L]
AddDefaultCharset utf-8

RewriteRule ^checkout/               /index.php?mod=checkout&action=show [NC,L,QSA]

index.php

case 'checkout':
    $action = isset($_GET['action']) ? $_GET['action'] : '';
    switch ($action) {
        case 'completed':
            # ...
            break;

        case 'cancelled':
            # ...
            break;

        case 'credentials':
        case 'shipment':
        case 'payment':
        case 'edit':
        default:
            include $_SERVER['DOCUMENT_ROOT'].'checkout/show.php';
            break;
    }
    break;

Progress

  • I've dumped the session variable to see if there was something strange in the session. (Nothing strange here)
  • I've installed a Tamper Data plugin for firefox to check the POST data. (Nothing strange here either)

Update

I found something in my code I skipped when checking everything last time. This could however have something to do with my problem.

<script type="text/javascript">    
         window.history.forward();
         function noBack() { 
              window.history.forward(); 
         }
    </script>
</head>
<body onload="noBack();" onpageshow="if (event.persisted) noBack();" onunload="">

Workflow

/cart GET 200 OK
/checkout/credentials/ GET 304 OK
/checkout/credentials/ POST 304 OK
# edit
/checkout/credentials/ POST - Error 'Connection was reset'
# Refresh
/checkout/credentials/ POST 200 OK

解决方案

"Connection was reset"

Can sometimes mean a php crash. Without seeing the exact files it's hard to guess if and why this is happening.

Make sure to check the error_log, type: php --info | grep error to see what file it's being logged to (if you are on linux/unix).

My guess is a stray break; statement somewhere see this answer for a possible cause: http://stackoverflow.com/a/20036720/988324

You would find some trace of this in your error logs though. If you can provide this I might be able to help more.

这篇关于POST /重定向抛出一个'连接是reset`浏览器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆