我想用PUT请求发送数据。
我有一个用于发送数据的输入字段,希望通过提交来发送数据。
我的数据是JSON格式。
这只是一次渗透测试 - 因此必须是PUT请求。
以下是代码:
<header>
<meta charset="UTF-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script type="javascript">
$(document).ready(function(){
$(#submit).click(){
var xmlHttp = getNewHTTPObject(); //returns a XMLHttpRequest object
function chargeURLPut(url) {
var mimeType = "text/plain";
xmlHttp.open('PUT', url, true); // true : asynchrone false: synchrone
xmlHttp.setRequestHeader('Content-Type', mimeType);
xmlHttp.send($(#data).val();
}}});
</script>
</header>
<body>
<form>
Data:<br>
<input id="data" type="text" name="data" value="Mickey"><br>
<input id="submit" type="submit" value="Submit">
</form>
</body>
</html>
但数据会像GET参数一样添加到URL中,我想在HTTP头之后获得数据,例如"{date: foo....}"。
以下是请求示例:
PUT /foo/bar/v1/users HTTP/1.1
Host: www.foo.bar
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0
Accept: */*
Accept-Language: de,en-US;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate, br
Referer: https://www.foo.bar/frontend/
Content-Type: application/json;charset=UTF-8
Authorization: eyJhbGciOiJSUzUxMiJ9.eyJzdW
origin: https://www.foo.bar
Content-Length: 598
Connection: close
{foo: bar, foo:bar}
type="javascript"
的情况下运行。 - UltimaterxmlHttp.send($(#data).val();
应该是xmlHttp.send($(#data).val());
。 - kevingreen