Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are commands to make a HTTP GET/POST request from an adb debugger?

Tags:

android

adb

I'd like to make some scripted like network traffic from an android phone. Is it possible to complete the task by making an HTTP request from adb shell? I noticed there is "adb shell ping" command that may test the network connectivity, but it does not generate HTTP request. I am thinking something like some utility similar to telnet.

EDIT: I see Open a broswer will serve my purpose, although not quite elegantly Need command line to start web browser using adb

like image 903
SkyOasis Avatar asked Oct 30 '15 01:10

SkyOasis


1 Answers

Netcat may work, if available:

$ nc www.example.com 80
GET / HTTP/1.1
Host: www.example.com

i.e. enter the first line on the command line, and the two HTTP protocol lines to standard input.

This returns:

HTTP/1.1 200 OK
Age: 185995
Cache-Control: max-age=604800
Content-Type: text/html; charset=UTF-8
Date: Mon, 10 May 2021 10:39:58 GMT
Etag: "3147526947+gzip+ident"
Expires: Mon, 17 May 2021 10:39:58 GMT
Last-Modified: Thu, 17 Oct 2019 07:18:26 GMT
Server: ECS (nyb/1D07)
Vary: Accept-Encoding
X-Cache: HIT
Content-Length: 1256

<!doctype html>
<html>
<head>
    <title>Example Domain</title>
...
like image 133
wodow Avatar answered Jan 03 '23 16:01

wodow