Guest User

Untitled

a guest
Sep 29th, 2022
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.75 KB | Source Code | 0 0
  1. void testrequest()
  2. {
  3.     WiFiClient client;
  4.     char* host_loc = "192.168.0.110";
  5.     int port_loc = 9091;
  6.     if (!client.connect(host_loc, port_loc))
  7.     {
  8.         Serial.println("connection failed");
  9.         return;
  10.     }
  11.     else
  12.     {
  13.         Serial.println("ok1");
  14.     }
  15.  
  16.     String r =(String("PUT /metrics/job/myardujob HTTP/1.1\r\n")+
  17.     "Accept-Encoding: identity\r\n"+
  18.     //"Content-Length: 82\r\n"+
  19.     "Host: "+host_loc+":"+port_loc+"\r\n"+
  20.     "User-Agent: Python-urllib/3.10\r\n"+
  21.     "Content-Type: text/plain; version=0.0.4; charset=utf-8\r\n"+
  22.     "Connection: close\r\n"+
  23.     "\r\n"+
  24.     "# HELP my_metric descripion of a metric created by arduino\r\n"+
  25.     "# TYPE my_metric gauge\r\n"+
  26.     "my_metric 1337\r\n");
  27.  
  28.     client.print(r);
  29.  
  30.     Serial.println("ok2");
  31.     while(1)
  32.     {
  33.     delay(1000);
  34.     }
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment