标签: http-post

缺少代理服务器的POST参数

我们的Web应用程序遇到了一些奇怪的行为.有些POST请求没有任何http正文.content-length为0.根本没有post参数.我们在我们的负载均衡器上跟踪网络流量,我们发现我们没有得到任何请求正文和我们的一些POST请求.

所有损坏的POST请求都有共同点,它们通过代理服务器到达.

我们已经在SO上找到了这个问题: 为什么POST请求中的"Content-Length:0"?

我们现在使用帧转义javascript例程,它有点帮助.似乎错误率下降.但是我们仍然有POST请求没有数据,这些数据在我们的webapp中永远不会发生.这些请求不是来自黑客或类似的.

我们经常看到webwasher作为代理.但大多数时候我们都没有看到使用了哪个代理.

在这篇PDF中,我们看到了关于使用webwasher缺少POST参数的评论

WebWasher - 透明认证指南

关于一些陷阱的说明

请注意,在设置透明身份验证时必须考虑一些缺陷:

如果ICAP服务器将重定向发送到身份验证服务器,则POST请求将失败.但是,这仅影响映射的更新,因为对于浏览器,请求成功,并且在最终重定向之后将不再发送POST正文.

我们想知道是否除了仅使用GET而不是POST之外还有一些解决方法.如果其他网站在POST数据丢失方面存在问题以及他们做出了哪些结论,我们也会在这里.

是否还有其他原因导致POST数据未发送?

proxy http-post

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

shell中的lwp-request:如何使用body发出POST请求?

我使用简单的shell脚本来测试一些处理POST请求的http服务器.通常它看起来像:

echo "param1=value1&param2=value2" | POST localhost/service
Run Code Online (Sandbox Code Playgroud)

但是现在我想在POST 主体中传递一些json ,这就是我完全错过点的地方.

男人POST和谷歌也没多大帮助.

似乎它必须非常简单或完全不可能.

感谢帮助.

shell http-post lwp

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

带有Javascript请求的Http Option方法

我使用backbone.js的模型.当我保存模型时,它会在firefox上向服务器端发送HTTP OPTIONS方法,但是使用safari发送HTTP POST方法.

我知道这不是关于backbone.js的问题,而是关于CORS.我将检查服务器端的方法,GET,POST,PUT和DELETE,我不会使用HTTP OPTIONS方法.

我要求的网址是我的api:api.foo.com和api要求:bar.com

那么,我如何控制所有浏览器请求我的api.foo.com使用HTTP POST而非OPTIONS?以及如何与来自任何其他域的所有请求共享api.foo.com的内容?

注意:我已经将响应的标头从服务器端更改为:Access-Control-Allow-Origin:*

http http-post cors http-options-method

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

使用Python从HTTP POST请求获取IP地址

我正在使用python脚本使用该BaseHTTPServer模块来执行我的Web服务器.下面是我的服务器代码:

import string,cgi,time
from os import curdir, sep
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
#import pri

class MyHandler(BaseHTTPRequestHandler):

    def do_GET(self):
        try:
        if self.path.endswith("/"):
        f = open(curdir + sep + "index.html")
        self.send_response(200)
        self.send_header('Content-type',    'text/html')
        self.end_headers()
        self.wfile.write("<HTML> GET OK.<BR>")
        f.close()
        return

            return

        except IOError:
            self.send_error(404,'File Not Found: %s' % self.path)


    def do_POST(self):
        global rootnode
        try:
            ctype, pdict = cgi.parse_header(self.headers.getheader('content-type'))
            if ctype == 'multipart/form-data':
                query=cgi.parse_multipart(self.rfile, pdict)
            self.send_response(200)
            self.send_header('Content-type',    'text/html')
        self.end_headers()
        file = query.get('file')
        self.wfile.write("<HTML> POST OK.<BR>")
        f = open("data.zip", "wb")
            f.write(file[0])
            f.close() …
Run Code Online (Sandbox Code Playgroud)

python http-post

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

在Swift中使用其他参数上传多个图像

现在,我一直只通过下面给出的代码将一个图像上传到服务器端脚本的服务器上.现在我有一个数组UIImage,我想知道如何使用它UIImageJPEGRepresentation(myImageView.image!, 0.1)来发布UIImageView数组中的所有图像?

func uploadImage()
{
    let postPictureUrl = NSURL(string: "http://www.23look.com/merchant/verify")
    let request = NSMutableURLRequest(URL: postPictureUrl!)
    request.HTTPMethod="POST"

    let param=[
        "mer_name" : shopNameUITF.text!,
        "mer_tel" : shopTelephoneUITF.text!,
        "mer_address" : shopAddressUITF.text!,
        "lat" : "39.6892",
        "lng" : "115.9239",
        "token": KeychainWrapper.stringForKey("tokenValue")!,
        "mer_type": "smalll"
    ]

    let abc =  KeychainWrapper.stringForKey("tokenValue")!

    let boundary = generateBoundaryString()

    request.setValue("multipart/form-data; boundary=\(boundary)", forHTTPHeaderField: "Content-Type")

    let imageData = UIImageJPEGRepresentation(myImageView.image!, 0.1)

    if imageData==nil { print("image data is nil"); return }

    request.HTTPBody = createBodyWithParameters(param, filePathKey: "mer_license", imageDataKey: imageData!, boundary: boundary)

    let …
Run Code Online (Sandbox Code Playgroud)

http-post uiimage ios swift

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

设置请求cookie angular2 http post请求

我有一个登录服务,执行http请求(到PHP后端服务器)并返回一个cookie.登录后,需要在客户端进行的所有进一步请求中使用此cookie.

login服务:

   login(userCredentials:UserCredentials):Observable<any> {    
        this.request.ServiceType = "Connect"
        this.request.SessionId = "sessionlessrequest"
        this.request.Compression = "no"
        this.request.Parameters = userCredentials;
        let jsonRequest = JSON.stringify(this.request)
        return this.http.post("http://localhost/request.php", "data="+ jsonRequest,
            { headers: new Headers({
                'Content-Type': 'application/x-www-form-urlencoded'
            })
            }).map( (responseData) => {
            this.apiResponse = responseData.json() as ApiResponse
            if (!this.apiResponse.Error) {
                this.sessionData.next(this.apiResponse.Data as UserSessionData)
                this.sessionData.asObservable().share
            } else {
                console.log(this.apiResponse.ErrorMessage)
            }
            return null
        })
Run Code Online (Sandbox Code Playgroud)

执行此调用时,cookie响应如下所示:
的getCookie

我看到我从session_start获取session_id(在我的php服务器上)

我在做请求的时候:

searchExams(searchObject:SearchObject):Observable<any>{
        let headers = new Headers();
        headers.append('Content-Type', 'application/x-www-form-urlencoded',)
        let options = new RequestOptions({ headers: headers, withCredentials: true});
        this.request.ServiceType = ServiceType.SearchExams;
        this.request.SessionId = …
Run Code Online (Sandbox Code Playgroud)

cookies http-post session-cookies angular

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

在PHP中回显$ _POST

我怎么打印$_POST?

例:

echo $_POST['data'];
Run Code Online (Sandbox Code Playgroud)

这没有任何回报......

php http-post

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

jQuery提交刷新页面

以下代码旨在执行纯粹的ajax POST请求,而不是它似乎通过ajax执行POST,然后浏览器导航到响应.

HTML ...

<div id="bin">
    <form class="add" method="post" action="/bin/add/">
        <p>I'm interested! Save for later.</p>
        <input type="hidden" name="product_id" value="23423">
        <input type="submit" value="Save">
    </form> 
    <form style="display:none;" class="remove" method="post" action="/bin/remove/">
        <p>I changed my mind--I'm not interested.</p>
        <input type="hidden" name="product_id" value="23423">
        <input type="submit" value="Unsave">
    </form>
</div>
Run Code Online (Sandbox Code Playgroud)

jQuery ......

$('#bin form').submit(function() {
                $.post($(this).attr('action'),{
                    success: function(data) { $(this).hide().siblings('form').show() },
                    data: $(this).serialize()

                });
                return false;
            })
Run Code Online (Sandbox Code Playgroud)

据我了解,该return false;行应意味着不管是什么,"提交"按钮,或在提交功能,或者点击任何呼叫进入我的功能将执行,浏览器就会手段的击球不是导航到/bin/add或/bin/remove.但由于某种原因,浏览器正在改变页面.

知道我在这里做错了吗?谢谢.

html javascript ajax jquery http-post

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

将 POST 请求从 asp.net core 控制器转发到不同的 URL

我想将传入的 POST 请求“按原样”(包括标头、正文、来自数据)转发到我的 asp.net core 控制器到不同的 URL,而不使用中间件。

我找到了一个为 asp.net 执行此操作的示例:https://philsversion.com/2012/09/06/creating-a-proxy-with-apicontroller/

但这不适用于 ASP.NET Core,因为调用 return wait http.SendAsync(this.Request); 在asp.net core中接受一个HttpRequestMessage,Request对象的类型是HttpRequest。

我还找到了一些代码,它从 HttpRequest 创建 HttpRequestMessage,请参阅:Convert Microsoft.AspNetCore.Http.HttpRequest to HttpRequestMessage

使用此代码,接收端点(我转发到的)将获取正文,但不会获取表单字段。

检查 HttpRequestMessage 类,我发现它不包含 FormFields 的属性。

[Microsoft.AspNetCore.Mvc.HttpPost]
[NrgsRoute("api/redirect-v1/{key}")]
public async Task<HttpResponseMessage> Forward(
   [FromUri] string key,
   CancellationToken cancellationToken)
{
   // the URL was shortened, we need to get the original URL to which we want to forward the POST request
   var url = await _shortenUrlService.GetUrlFromToken(key, cancellationToken).ConfigureAwait(false);

     using (var httpClient = new HttpClient())
     {
         var …
Run Code Online (Sandbox Code Playgroud)

http-post httprequest asp.net-core

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

PSR-7:getParsedBody() 与 getBody()

场景一发送x-www-form-urlencoded数据

POST /path HTTP/1.1
Content-Type: application/x-www-form-urlencoded

foo=bar
Run Code Online (Sandbox Code Playgroud)

运行print_r($request->getParsedBody());返回正常:

Array
(
    [foo] => bar
)
Run Code Online (Sandbox Code Playgroud)

运行print_r($request->getBody()->getContents());返回一个字符串foo=bar


场景2发送application/json数据

POST /path HTTP/1.1
Content-Type: application/json

{
    "foo": "bar"
}
Run Code Online (Sandbox Code Playgroud)

运行print_r($request->getParsedBody());返回一个空数组。Array ( )

但是,运行print_r($request->getBody()->getContents());效果很好:

{"foo":"bar"}


这是预期的行为吗?

这意味着,如果我们要发送x-www-form-urlencoded数据,我们应该使用getParsedBody().

getBody()->getContents()如果我们发送 application/json?则应使用while 。


附加信息:

请求对象是使用以下命令创建的:

$request = \Laminas\Diactoros\ServerRequestFactory::fromGlobals(
        $_SERVER, $_GET, $_POST, $_COOKIE, $_FILES
);
Run Code Online (Sandbox Code Playgroud)

php post json http-post psr-7

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