2016-03-27 49 views
0

bir post isteğini yanıtlamaBen bir post isteği göndermek

$.ajax({ 
    url: "http://localhost:5002", 
    type: "POST", 
    async: false, 
    cache: false, 
    data: "username=" + "heyyyys", 
    success: function(response) { 
    alert(response); 
    return response;   
    } 
}); 

başarıyla bir isteği Burada

int result = recv(server, buffer, bufSize, 0); 
cout << buffer << endl; 

kabul sahip tamponu:

POST/HTTP/1.1 
Host: localhost:5002 
Connection: keep-alive 
Content-Length: 16 
Accept: */* 
Origin: http://localhost 
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36 
Content-Type: application/x-www-form-urlencoded; charset=UTF-8 
Referer: http://localhost/osrm/main.html 
Accept-Encoding: gzip, deflate 
Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4 

username=heyyyys 

Ben

cevap çalışıyorum
response << "POST/HTTP/1.1\r\n" 
<< "HOST: localhost:5002\r\n" 
<< "User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36" 
<< "Content-Type: application/x-www-form-urlencoded; charset=UTF-8\r\n" 
<< "Accept: */*\r\n" 
<< "Content-Length: 4\r\n" 
<< "Connection: close\r\n\r\n"; 
<< "resp"; 
send(server, response.str().c_str(), response.str().length(), 0); 

Ama cevap vermek imkansız. Hatamı söyle bana.

+1

geri sonrası isteği gönderiyor, bir sonuç ... yangın kemancıyı ya da kromu/devasa araçlarını bulup birkaç asıl gönderi isteğine ve yanıtına bakın ve probleminiz oldukça açık olmalıdır. – casey

cevap

0

Teşekkür Casey, Ben oluşturulduğu krom dev araçları ve böyle bir tepkinin temelinde sonrası isteklerinin örneklerini gördük:

HTTP/1.1 200 OK 
Date: Sun, 10 Oct 2010 23:26:07 GMT 
Accept-Ranges: bytes 
Content-Length: 11 
Access-Control-Allow-Origin: * 
Connection: close 
Content-Type: text/html; charset=UTF-8 

hello world! 
İlgili konular