HTTP/HTTPS 통신연습 → Get Request
The following commands show how to send an HTTP GET request to the server, and how to read HTTP response.
1. HTTP-GET 명령시퀀스
NO | Command | Response | 설명 |
1 | PDP Context 설정 | ||
2 | AT+HTTPINIT | OK |
(1) PDP Context 활성화 (2) HTTP Service 시작 |
3 |
AT+HTTPPARA=”URL” ,”http://ipinfo.io” |
OK |
Set an URL to be accessed for HTTP (IP를 조회하고자 함) |
– |
AT+HTTPPARA=”URL” ,”https://ipinfo.io” |
OK |
Set an URL to be accessed for HTTPS (IP를 조회하고자 함) |
4 | AT+HTTPACTION=0 |
OK +HTTPACTION: 0,200,292 |
Send HTTP GET request |
5 | AT+HTTPHEAD | +HTTPHEAD: DATA,375 HTTP/1.0 200 OK access-control-allow-origin: * x-frame-options: SAMEORIGIN x-xss-protection: 1; mode=block x-content-type-options: nosniff referrer-policy: strict-origin-when-cross-origin content-type: application/json; charset=utf-8 content-length: 292 date: Sat, 27 Nov 2021 07:31:43 GMT x-envoy-upstream-service-time: 1 vary: Accept-Encoding Via: 1.1 googleOK |
Read the HTTP response header |
6 | AT+HTTPREAD? |
+HTTPREAD: LEN,292 OK |
|
7 | AT+HTTPREAD=0,292 |
OK +HTTPREAD: DATA,292 +HTTPREAD: 0 |
나의 IP=111.65.45.223 임을 확인할 수 있음. |
8 | AT+HTTPTERM | OK | Stop HTTP Service |