• Система автоматизации с открытым исходным кодом на базе esp8266/esp32 микроконтроллеров и приложения IoT Manager. Наша группа в Telegram

ESP8266+Arduino+ASP.Net запросы

iv-med

New member
Здравствуйте!
Как добиться правильного GET или POST запроса на страницу aspx, чтобы не было ответа:
HTML:
<!DKCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Bad Request</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Bad Request</h2>
<hr><p>HTTP Error 400. The request is badly formed.</p>
</BODY></HTML>
соединяюсь по вафле с сайтом, отправляю команду:
Код:
GET /RFID.aspx?UID=434343 HTTP/1.1\r\nHost: pzs-dstu.tk\r\nConnection: keep-alive\r\nCache-Control: max-age=0\r\nUpgrade-Insecure-Requests: 1\r\nUser-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36\r\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\r\nAccept-Encoding: gzip, deflate, sdch\r\nAccept-Language: ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4,uk;q=0.2\r\nCookie: b=b\r\n
и в ответ всё 400 ошибка
 

pvvx

Активный участник сообщества
Код:
Initializing WIFI ...
WIFI initialized

Interface 0 IP address : 192.168.1.122
Starting connection to server...

Connect to Server successful!
connected to server
HTTP/1.1 200 OK
Cache-Control: private
Content-Type: text/html; charset=utf-8
Server: Microsoft-IIS/8.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Sat, 24 Dec 2016 20:02:51 GMT
Connection: close
Content-Length: 570



<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>

</title></head>
<body>

</body>
</html>
<!--SCRIPT GENERATED BY SERVER! PLEASE REMOVE-->
<center><a href="http://somee.com">Web hosting by Somee.com</a></center>
</textarea></xml></script></noframes></noscript></object></layer></style></title></applet>
<script language="JavaScript" src="http://ads.mgmt.somee.com/serveimages/ad2/WholeInsert4.js"></script>
<!--SCRIPT GENERATED BY SERVER! PLEASE REMOVE-->
disconnecting from server.
Код:
#include <WiFi.h>
char ssid[] = "yourNetwork"; //  your network SSID (name)
char pass[] = "password";    // your network password (use for WPA, or use as key for WEP)

char server[] = "pzs-dstu.tk";    // name address for Google (using DNS)

WiFiClient client;
void setup() {
  while (WiFi.begin(ssid, pass) != WL_CONNECTED) delay(100); // wait 0.1 seconds for connection
  printf("\nStarting connection to server...\n");
  if (client.connect(server, 80)) {
    Serial.println("connected to server");
    // Make a HTTP request:
    client.println("GET /RFID.aspx?UID=434343 HTTP/1.1");
    client.println("Host: pzs-dstu.tk");
    client.println("Connection: close");
    client.println();
  }
}

void loop() {
  // if there are incoming bytes available
  // from the server, read them and print them:
  while (client.available()) {
    Serial.write(client.read());
  }

  // if the server's disconnected, stop the client:
  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting from server.");
    client.stop();
    // do nothing forevermore:
    while (true);
  }
}
 
Сверху Снизу