6

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

Community
  • 1
  • 1
SkyOasis
  • 943
  • 2
  • 11
  • 24
  • 4
    `adb shell ping` is just executing /system/bin/ping in a shell. There's no telnet/curl/wget/... utilities on stock Android, but if you copy a version of busybox onto your phone, you should be able to do "adb shell busybox wget " to generate HTTP get requests. – adelphus Oct 30 '15 at 01:24

1 Answers1

2

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>
...
wodow
  • 3,257
  • 4
  • 28
  • 44