标签: http-post

来自同一台机器的GET和POST请求可以来自不同的IP吗?

我很确定我记得读过 - 但是找不到链接了 - 关于这个:在一些ISP(包括美国至少一个大型ISP)上,有可能让用户的GET和POST请求出现来自不同的IP.

(请注意,这完全与编程有关,我将在下面举例说明)

我不是说你的IP地址在两个请求之间动态变化.

我在说这个:

IP 1:  123.45.67.89
IP 2:  101.22.33.44
Run Code Online (Sandbox Code Playgroud)

在相同的用户发出GET,那么一个帖子,然后再得到,然后再次发布和服务器看到这一点:

- GET  from IP 1
- POST from IP 2
- GET  from IP 1
- POST from IP 2
Run Code Online (Sandbox Code Playgroud)

因此,尽管它是同一个用户,但Web服务器会看到GET和POST的不同IP.

肯定看到HTTP是无状态协议,这是完全合法的吗?

我想找回关于某些ISP如何/为什么配置其网络以便可能发生这种情况的解释.

我问,因为有人要求我实施以下IP过滤器,我很确定它是从根本上破坏了代码(破坏了至少一个主要的美国ISP用户的破坏).

这是一个Java servlet过滤器,可以防止某些攻击.原因是:

" 对于任何会话过滤器检查请求中的IP地址是否与创建会话时使用的相同.因此,在这种情况下,会话ID不能被盗用于形成虚假会话."

http://www.servletsuite.com/servlets/protectsessionsflt.htm

但是我很确定这本身就是破坏的,因为有些ISP可能会看到来自不同IP的GET和POST.

ip http-get http-post

4
推荐指数
1
解决办法
303
查看次数

PHP Curl脚本生成重复请求

我有一个基于PHP Curl的函数,用于应用程序中的各种请求.该功能通常用于在同一台机器(localhost)上的其他服务器上通信/触发请求.功能如下: -

/**
 * @desc If a curl_multi handle is passed, a new curl 
 * instance is added to the handle and the curl id is returned as string.
 * @param string $theServer
 * @param string $thePath
 * @param number $thePort
 * @param curl_multi $mcHandle
 * @return string|curl_handle
 */
function sendPOSTtoURL($theServer, $thePath, $theData, 
                        $thePort = 80, $mcHandle = null) {
    global $bDebug; $theResult = "";    //$bDebug = true;
    $cPost = curl_init();
    if ($cPost !== false)   {
        curl_setopt($cPost, CURLOPT_URL, "http://".$theServer.$thePath); …
Run Code Online (Sandbox Code Playgroud)

php curl http http-post

4
推荐指数
1
解决办法
2980
查看次数

Classic ASP中的URL编码

可以使用VBScript转义来转发帖子(application/x-www-form-urlencoded)或多部分帖子吗?它是否相当于PHP的urlencode?

vbscript http-post asp-classic

4
推荐指数
1
解决办法
1643
查看次数

如何在MultipartEntity中传递字符串变量?

我正在传递3张图片MultipartEntity.这很好用,但我不知道如何传递一个String值MultipartEntity.以下是我的代码:

public void executeMultipartPost(Bitmap bm, int i) throws Exception {
    try {
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        bm.compress(CompressFormat.JPEG, 75, bos);
        byte[] data = bos.toByteArray();
        HttpClient httpClient = new DefaultHttpClient();
        HttpPost postRequest = new HttpPost("http://www.3dsoles.com/droidapp/index.php");

        ByteArrayBody bab = new ByteArrayBody(data, "image" + i + ".jpg");
        // File file= new File("/mnt/sdcard/forest.png");
        // FileBody bin = new FileBody(file);
        MultipartEntity reqEntity = new MultipartEntity(
        HttpMultipartMode.BROWSER_COMPATIBLE);
        reqEntity.addPart("file", bab);
        // reqEntity.addPart("userID", Constants.mUserImei);
        reqEntity.addPart("photoCaption", new StringBody("sfsdfsdf"));
        postRequest.setEntity(reqEntity);
        HttpResponse response = httpClient.execute(postRequest); …
Run Code Online (Sandbox Code Playgroud)

android httpclient http-post image-uploading multipartentity

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

在Objective C中通过POST上传图像

我目前正在通过HTTP Post将图像上传到服务器,似乎无法找到构建调用服务的URL的方法.用户从库或相机中选择一个图像,然后调用执行insert语句的json服务.

该服务期待以下uritemplate:

@"%@/DataTransfer/SetUserProfileImage?EMP_ID=%@&image=%@&imageName=%@"
Run Code Online (Sandbox Code Playgroud)

期望图像数据以某种方式转换为字符串并通过URL发送.

这是我目前的代码:

- (BOOL)setUserProfileImage:(UIImage *)imgUser Name:(NSString *)strName{

    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];

    NSData *dataImage = UIImagePNGRepresentation(imgUser);

    NSString* theNSString = [[NSString alloc] initWithData:dataImage encoding:NSASCIIStringEncoding];

    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@/DataTransfer    /SetUserProfileImage?EMP_ID=%@&"
                                   "image=%@&imageName=%@",
                                   appDelegate.ServerAddress, 
                                   appDelegate.UserId,
                                   theNSString,
                                   strName]];

    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url 
                                                       cachePolicy: NSURLRequestUseProtocolCachePolicy
                                                   timeoutInterval:10.0];

    [request setHTTPMethod:@"POST"];
    [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];


    NSURLResponse* response = nil;
   NSError* resultError = nil;

   NSData* data = [NSURLConnection sendSynchronousRequest:request 
                                     returningResponse:&response 
                                                 error:&resultError];

   NSString *strResult = [[NSString alloc] initWithBytes:[data bytes] 
                                               length:[data length] 
                                             encoding:NSUTF8StringEncoding]; 

   BOOL …
Run Code Online (Sandbox Code Playgroud)

objective-c http-post uiimage

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

使用POST的异步cURL

我正在制作一个命令行应用程序.我需要在执行登录过程后同时通过cURL发出多个POST请求 - 这意味着传出请求必须发送会话ID等.

事件链如下:

  1. 我用curl_init打开cURL连接
  2. 我使用curl_exec登录远程站点发送POST请求,并获得返回的HTML代码作为响应
  3. 我同时向同一站点发送多个POST请求.

我在考虑使用类似的东西:

// Init connection

$ch = curl_init();

// Set curl options

curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookies.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookies.txt');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_POST, 1);

// Perform login

curl_setopt($ch, CURLOPT_URL, "http://www.mysite/login.php");
$post = array('username' => 'username' , 'password' => 'password');
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
$result = curl_exec($ch);

// Send multiple requests after being logged on

curl_setopt($ch, CURLOPT_TIMEOUT_MS, 1);

for($i = 0 ; $i < 10 ; $i++){
    $post = array('myvar' => …
Run Code Online (Sandbox Code Playgroud)

php curl http-post

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

CherryPy:如何将路由限制为仅POST

我有一个网页形式,看起来像:

<form action="/process_form/" method="post">
  <input type="text" name="login" value="login" />
  <input type="text" name="password" value="123" />
  <input type="submit" />
</form>
Run Code Online (Sandbox Code Playgroud)

处理这个问题的python类是:

class Handle:
  @cherrypy.expose()
  #@cherrypy.tools.post <-- Is something like this possible
  def index(self, login=None):
    print(login)
Run Code Online (Sandbox Code Playgroud)

CherryPy中有一种方法可以限制/process_form/对POST方法的调用吗?我的意思是如果用户输入http://www.example.com/process_form/他/她应该得到异常/错误或找不到页面?

cherrypy http-post python-3.x

4
推荐指数
1
解决办法
1346
查看次数

如何在没有cURL的情况下使用PHP HTTP发布XML文件?

我有一个从Table In MySql创建的XML,我需要创建一个HTTP Post来将XML插入到Web服务中.Web Service只接受SOAP,HTTP POST和HTTP GET方法.我尝试以不同的方式发出HTTP POST请求而根本没有运气.我之前从未使用过SOAP.如何进行HTTP POST或SOAP请求?

post_xml.xml:

<?xml version="1.0" encoding="utf-8"?>
<?ADF version="1.0"?>
<adf>
<prospect><id sequence="1" source="xxxs">37</id>
<requestdate>2013-07-10 06:10:42</requestdate>
<vehicle interest="buy" status="new">
<year>2013</year>
<make>12</make>
<model>21</model>
<trim>Sport</trim>
</vehicle>
<customer>
<contact>
<name part="first">Jay</name>
<name part="last">11z</name>
<email>test@gmail.com</email>
<phone time="morning" type="voice" preferredcontact="1">99999999</phone>
<address>
<street line="1">1130 E Test</street>
<city>sa</city>
<regioncode>Z</regioncode>
<postalcode>79924</postalcode>
<country>USA</country>
</address>
</contact>
</prospect>
</adf>
Run Code Online (Sandbox Code Playgroud)

client1.php(HTTP POST代码)

$xml = file_get_contents('post_xml.xml');
$url = 'http://stg.sa.com/post.asmx/';

$post_data = array ("XML" => $xml);
$stream_options = array(
    $url => array(
        'method'  => 'POST',
        'header'  => 'Content-type: application/x-www-form-urlencoded' …
Run Code Online (Sandbox Code Playgroud)

php xml http-post

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

Python'请求'模块中的POST请求无法正常工作

POST https://maxcvservices.dnb.com/rest/Authentication
x-dnb-user: MyUsername
x-dnb-pwd: MyPassword
Run Code Online (Sandbox Code Playgroud)

是D&B API的文档,因此我尝试使用以下代码行使用python请求模块发送POST请求:

r = requests.post('https://maxcvservices.dnb.com/rest/Authentication',params={'x-dnb-user':userid,'x-dnb-pwd':pass})
Run Code Online (Sandbox Code Playgroud)

我得到的回应是 Response [500]

并且回复的内容是: error processing request\r\n

我的问题是,在传递帖子请求和参数时我是否做错了,还是我的用户名和密码无效?

我觉得问题在于我传递POST请求的方式,因为API响应错误的用户ID,传递单独的错误401.

{'connection': 'Keep-Alive',
 'content-encoding': 'gzip',
 'content-length': '46',
 'content-type': 'text/plain',
 'date': 'Sat, 26 Oct 2013 17:43:22 GMT',
 'server': '',
 'vary': 'Accept-Encoding',
 'x-correlationid': 'Id-d4c07ad3526bff3a03fb742e 0'}
Run Code Online (Sandbox Code Playgroud)

我使用时的响应标题:

r = requests.post('https://maxcvservices.dnb.com/rest/Authentication', headers={'x-dnb-user': 'userid', 'x-dnb-pwd': 'password'})
Run Code Online (Sandbox Code Playgroud)

随机用户ID和密码.

但根据我应该收到的API <Response [401]>.我收到了<Response [500]>.

python http-post python-requests

4
推荐指数
1
解决办法
7726
查看次数

ios http POST(数据和图像):图像未发布

我使用以下代码将图像和数据推送到服务器中.正在发送数据,但未在服务器中接收图像.如果我使用下面的代码中有错误,有人可以发现我:

NSString *urlString = [[NSString alloc]initWithString:[NSString stringWithFormat:@"%@action=savesign",MainURL]];

// set up the form keys and values (revise using 1 NSDictionary at some point - neater than 2 arrays)
NSArray *keys = [[NSArray alloc] initWithObjects:@"user",@"poll",nil];
NSArray *vals = [[NSArray alloc] initWithObjects:user,pollid,nil];

// set up the request object
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:[NSURL URLWithString:urlString]];
[request setHTTPMethod:@"POST"];

//Add content-type to Header. Need to use a string boundary for data uploading.
NSString *boundary = @"0xKhTmLbOuNdArY";
NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@",boundary];
[request …
Run Code Online (Sandbox Code Playgroud)

cocoa-touch image objective-c http-post ios

4
推荐指数
1
解决办法
3999
查看次数