标签: http-post

使用http post评级系统 - 避免滥用

我有一个用于使用POST的html用于评估图像.这些图像是使用SQL随机选择的.

一旦我提出它,我注意到一些用户(使用用户ID识别)能够在短时间内为他们选择的图像投票多次.很可能他们正在利用http POST处理方式的缺陷.

作为临时解决方案,我添加了一些代码来检查图像是否在过去一小时内被同一个人评级.这可行但不理想,因为图像可以在较短的时间内随机出现.

那么,我怎样才能确保对显示的图像进行单一评级,并拒绝相同随机选择的任何连续评级?

PS:我可能会向匿名用户开放,因此欢迎使用会话的任何建议.

html php mysql sql http-post

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

Django - 模拟一个http-post请求

我有这个视图功能search(request).网址后缀是/search.它需要一些POST参数并相应地显示搜索结果.

我想做第二个功能show_popular(request).它不需要发布或获取参数.但是它应该使用一些硬编码的post参数来模拟对搜索功能的调用.

我希望在不改变现有功能和改变设置的情况下实现这一点.那可能吗?

编辑:我知道这可以通过将搜索重构为一个单独的函数并让几个视图函数调用它来实现.但在这种特殊情况下,我对此并不感兴趣.在我的情况下,show_popular函数只是临时的,出于不相关的原因,我不想重新考虑因素.

django http-post

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

使用nodejs将文档索引到elasticsearch

我试图使用nodejs将文档索引到elasticsearch.我使用node.js中http库.当我执行我的测试时,我得到:

> node test2.js
data=(bodyText=bodytext)
STATUS: 400
HEADERS: {"content-type":"application/json; charset=UTF-8","content-length":"906"}
response: {"error":"ElasticSearchParseException[Failed to derive xcontent from (offset=0, length=17): [98, 111, 100, 121, 84, 101, 120, 116, 61, 98, 111, 100, 121, 116, 101, 120, 116, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
Run Code Online (Sandbox Code Playgroud)

javascript http http-post node.js elasticsearch

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

如何从PHP代码中轻松地进行POST?

可能重复:
PHP + curl,HTTP POST示例代码?
POST数据到URL php
如何发出HTTP POST请求?

我创建了一个拦截常规帖子的脚本,并根据用户名做了一件事.

在其中一个条件分支中,我想移动用户并将他在登录表单中写下的内容POST到另一个PHP脚本.

如何轻松地向URL发出POST请求?

是否有类似的东西:

$data = array("username" => "admin", "password" => "hunter2");

http_post("foo.com", "POST", $data);
Run Code Online (Sandbox Code Playgroud)

有什么建议?

php http-post

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

IP地址上的Node.js HTTPS POST请求失败

我正在尝试使用以下脚本创建HTTPS POST SOAP请求:

var http = require('http');

function Authenticate() {
  // Build the post string from an object
  var post_data = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:typ=\"http://company.com/mse/types\"><soapenv:Header/><soapenv:Body><typ:Login><typ:Credential userName=\"username\" password=\"password\"/></typ:Login></soapenv:Body></soapenv:Envelope>";
  // An object of options to indicate where to post to

  var post_options = {
    port: 443,
    host: 'https://132.33.223.33', //MSE12
    path: '/aaa/',
    method: 'POST',

    headers: {
        'Content-Type': 'text/xml;charset=UTF-8',
        'SOAPAction': '\"Login\"',
        'Accept-Encoding': 'gzip,deflate',
        'Host':'173.37.206.33',
        'Connection':'Keep-Alive',
        'User-Agent':'Apache-HttpClient/4.1.1 (java 1.5)'
    }
  };

  // Set up the request
  var post_req = http.request(post_options, function(res) {
      res.setEncoding('utf8');
      res.on('data', …
Run Code Online (Sandbox Code Playgroud)

https http http-post node.js

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

我可以在不使用序列化程序功能的情况下通过HTTP-POST发布字符串数组吗?

如何在没有序列化的情况下通过HTTP-POST发布字符串数组(编辑:不使用序列化函数)?例如:

 $d1 = array ("2","5","1","3");
Run Code Online (Sandbox Code Playgroud)

php http-post

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

Ajax如何将大数据发布到asp.net web表单webMethod

我正在尝试使用ajax帖子将图像发送到asp.net Web表单

function SubmitFunction() {            
            alert(imgData_Based64String);
            imgData_Based64String = "test";
            $.ajax({
                type: "POST",
                contentType: "application/json; charset=utf-8",
                url: "WebForm1.aspx/SaveImage",
                data: "{ 'Based64BinaryString' :'" + imgData_Based64String + "'}",
                dataType: "json",
                success: function (data) {

                },
                error: function (result) {
                    alert("Error");
                }
            });
        }


    [System.Web.Services.WebMethod]
    public static void SaveImage(string Based64BinaryString)
    {
        string Value = Based64BinaryString;
    }
Run Code Online (Sandbox Code Playgroud)

一切都好.
"test"消息到达服务器端的SaveImage函数.
但当我尝试发送实际的基于64string(删除"测试"虚拟消息后)

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAoAAAAHgCAYAAAA10 ....
Run Code Online (Sandbox Code Playgroud)

它永远不会达到服务器端的SaveImage功能.它仅在浏览器开发者模式下显示以下错误.

Failed to load resource: the server responded with a status of 500 (Internal Server Error) 
Run Code Online (Sandbox Code Playgroud)

c# asp.net ajax jquery http-post

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

Stream 在放置 HTTP Post 请求时不支持读取

我面临一个错误,即“流不支持阅读”。我正在向 url 发出 Http post 请求。下面是我正在使用的代码

var request = (HttpWebRequest) WebRequest.Create("https://test.com/Hotel Hospitality Source?method=fetchInfo");

var postData = "&username=testing";
postData += "&password=Testing";
postData += "&hotelId=h075-103";
var data = Encoding.ASCII.GetBytes(postData);

request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = data.Length;
using(var ms = new MemoryStream())
request.GetRequestStream().CopyTo(ms);

var response = (HttpWebResponse) request.GetResponse();

var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
Run Code Online (Sandbox Code Playgroud)

首先我使用了下面的代码。

 using (var stream = request.GetRequestStream())
 {
     stream.Write(data, 0, data.Length);
 }

 var response = (HttpWebResponse)request.GetResponse();

 var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

当我使用 CopyTo 方法进行流时出现错误。我该如何解决这个错误?

c# http-post filestream

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

Delphi tidhttp编码特殊字符

我已将应用程序从D2007升级到XE6.它将数据发布到网络服务器.

我无法确定哪些编码将正确发送左右引号字符(下面的代码片段).我已经尝试了我能找到的每个选项,但是它们?在发送时被编码(就我在WireShark中看到的那样).

D2007没有问题,但XE6完全是关于Unicode的,我不确定问题是编码还是代码页或什么.

  Params := TIdMultipartFormDataStream.Create;
  params.AddFormField('TEST', 'Test ‘n’ Try', 'utf8').ContentTransfer := '8bit';
  IdHTTP1.Request.ContentType := 'text/plain';
  IdHTTP1.Request.Charset := 'utf-8';
  IdHTTP1.Post('http://test.com.au/TestEncoding.php', Params, Stream);
Run Code Online (Sandbox Code Playgroud)

delphi http-post character-encoding

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

POST请求有效内容的内容类型

我在POST请求中发送了JSON正文,但是http.DetectContentType将其标识为文本/纯文本类型。

我想灵活地根据其内容类型来处理请求有效负载-如果是XML {}如果是JSON {}否则是{否处理}

为了实现此条件处理,我使用http.DetectContentType返回请求的内容类型,但在每种情况下都将返回文本/纯文本。

func Test(w http.ResponseWriter, r *http.Request) *ErrorObject {

        reqBuffer := make([]byte, 512)
        _, err := r.Body.Read(reqBuffer)
        if err != nil {

    return ErrorObject{}.New(1, err, nil)
}

contentType := GetContentType(reqBuffer)
fmt.Printf(contentType)

    if contentType == "application/xml" || contentType == "text/xml" {
    w.Header().Set("Content-Type", "application/xml; charset=UTF-8") ...}
    if contentType == "application/json" || contentType == "text/json" {
    w.Header().Set("Content-Type", "application/json; charset=UTF-8") ... } 
    else return Invalid Request Type error
} 

   func GetContentType(buffer []byte) string {

       fmt.Println(string(buffer))
       contentType := http.DetectContentType(buffer)
       fmt.Printf(contentType)
       return contentType …
Run Code Online (Sandbox Code Playgroud)

xml rest json http-post go

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