简体   繁体   English

Chrome扩展程序的POST请求导致500错误

[英]POST request from Chrome extension results in 500 error

I'm making a POST request from a Chrome extension that appears identical to the one that submitting the form manually would do. 我正在从Chrome扩展程序发出POST请求,该请求看起来与手动提交表单的请求相同。 I've submitted both and compared the body and headers and they seem to be identical. 我已经提交了两者,并比较了正文和标题,它们似乎是相同的。

The POST made via the browser form results in a 302 redirect. 通过浏览器表单进行的POST导致302重定向。 The POSTed entry is created and the user ends up on an edit screen for it. POSTED条目已创建,并且用户最终在其编辑屏幕上。

The POST made via the extension results in a 500 error. 通过扩展名进行的POST导致500错误。

I'm filtering many of the headers sent by the extension to match those made by the browser, in case the server is looking for certain things that tip off a request as being non-native. 我正在过滤扩展程序发送的许多标头,以匹配浏览器的标头,以防服务器正在寻找某些提示,使请求成为非本地标头。

Hoping to exhaust all options before contacting the devs of the system being POSTed to. 希望在联系发布系统的开发人员之前用尽所有选项。 Any obvious things that could be happening server-side to block this request? 服务器端可能发生任何明显的事情来阻止此请求?

Here's the POST request made via the browser form: 这是通过浏览器表单发出的POST请求:

Request Headers 请求标题

Host: myhost.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:53.0) Gecko/20100101 Firefox/53.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Content-Type: application/x-www-form-urlencoded
Content-Length: 901
Referer: https://myhost.com/referer
Cookie: app2=cookieredacted
Connection: keep-alive
Upgrade-Insecure-Requests: 1
Pragma: no-cache
Cache-Control: no-cache

Request Body 请求正文

record[user_name]=aasldkjflasdjf
record[new_password]=ljl;jl;kjklj
record[first_name]=ethan
record[middle_name]
record[last_name]=lastnm
record[name_suffix]
record[gender]=M
record[dob]=07/28/77
record[ssn]=654656546
record[group_number]
record[misc_number]
record[mothers_maiden_name]
record[active]=N
record[active]=Y
record[has_paper_chart]=0
record[notes]
record[address1]=234+htha+st
record[address2]
record[city]=euge
record[county_of_residence]
record[state]=OR
record[zip]=98754
record[country]
record[tel1]=5155555555
record[tel1_status]=4
record[tel2]
record[tel2_status]
record[cell]
record[cell_status]
record[email]=ethan@foo.com
record[preferred_contact]=home_tel
record[house]
record[room]
record[bed]
record[classroom]

Response Headers 响应标题

Server: nginx/1.6.2
Date: Sun, 09 Jul 2017 01:06:12 GMT
Content-Type: text/plain
Transfer-Encoding: chunked
Connection: keep-alive
Status: 302 Found
Location: /entry/edit

And from the extension: 从扩展名开始:

Request Headers 请求标题

Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding:gzip, deflate, br
Accept-Language:en-US,en;q=0.5
Cache-Control:no-cache
Connection:keep-alive
Content-Length:920
Content-Type:application/x-www-form-urlencoded
Cookie:app2=cookieredacted; gsScrollPos-2545=
Host:myhost.com
Pragma:no-cache
Referer:https://myhost.com/referer
Upgrade-Insecure-Requests:1
User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.50 Safari/537.36

Request Body 请求正文

new_password_stub:"FoECbiRN"
record[active]:"Y"
record[address1]:"123 N 5th St"
record[address2]:""
record[bed]:""
record[cell]:""
record[cell_status]:""
record[city]:"Eugene"
record[classroom]:""
record[country]:""
record[county_of_residence]:""
record[dob]:"9/28/91"
record[email]:"ethan@foo.com"
record[first_name]:"Foo"
record[gender]:"M"
record[group_number]:""
record[has_paper_chart]:0
record[house]:""
record[last_name]:"Bar"
record[middle_name]:""
record[misc_number]:""
record[mothers_maiden_name]:""
record[name_suffix]:""
record[new_password]:"FoECbiRN"
record[notes]:""
record[preferred_contact]:"home_tel"
record[room]:""
record[send_notifications]:0
record[ssn]:"222222222"
record[state]:"OR"
record[tel1]:"5155555555"
record[tel1_status]:2
record[tel2]:""
record[tel2_status]:""
record[user_name]:"BarFoo2017"
record[zip]:"97401"

Response Headers 响应标题

Cache-Control:no-cache
Connection:keep-alive
Content-Length:5110
Content-Type:text/html; charset=utf-8
Date:Sun, 09 Jul 2017 02:09:33 GMT
Server:nginx/1.6.2
Set-Cookie:mysite_session_id=; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 -0000
Status:500 Internal Server Error

Thanks to wOxxOm for this one - 感谢wOxxOm

The extension was posting an extra field record[send_notifications] which was causing the 500 error. 该扩展程序正在发布一个额外的字段record[send_notifications] ,这导致了500错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM