Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a standard header for mobile http requests that specifies device type, os version, app version etc?

I am creating a json API for my mobile clients and was wondering if there's already a standard like User-Agent to send information like

  • device type
  • device os
  • app version

Or any other thing my server would like to know about the client device...

Since mobile usage has grown so popular, it seems reasonable if there was a standard of some sort.

  1. Should I request my clients to send all this information in User-Agent header (even though the requests are not being sent by browsers) ?
  2. Should I create custom headers for these type of fields and perhaps prefix them with X-MyApp-... ?

I know I can chose to use any of the methods I like since it's my api and I can decide whatever I want, but i'm curious if there's any industry standard in that matter.

Thanks

like image 537
Michael Avatar asked Apr 27 '14 17:04

Michael


People also ask

Which HTTP request header contains browser and operating system information?

The HTTP headers User-Agent is a request header that allows a characteristic string that allows network protocol peers to identify the Operating System and Browser of the web-server.

What is HTTP General header?

General header is an outdated term used to refer to an HTTP header that can be used in both request and response messages, but which doesn't apply to the content itself (a header that applied to the content was called an entity header).

What is HTTP header format?

An HTTP header is a field of an HTTP request or response that passes additional context and metadata about the request or response. For example, a request message can use headers to indicate it's preferred media formats, while a response can use header to indicate the media format of the returned body.


1 Answers

There is no standard HTTP header for conveying device-specific information. I can't speak to what information the Android platform exposes, but I know that any iOS app that uses NSURLConnection to make HTTP requests uses a customised User-Agent string which is of the following format:

<App Name>/<App Version> CFNetwork/<CFNetwork version> Darwin/<kernel version>

There's a pretty handy list of CFNetwork versions that you could use to try to determine what version of iOS is running on the device making the calls. However, it's worth noting that sometimes the CFNetwork and kernel versions don't change between iOS releases. For example, CFNetwork/609.1.4 Darwin/13.0.0 is used by iOS 6.1.2, 6.1.3, and 6.1.4.

Your best bet is to define your own X-Header and transmit exactly the information you need. Prefixing the X-Header will reduce the likelihood of a header collision with another app, but since it's trivial to add a header to a request, you can't rule out spoofing or invalid data.

like image 116
neilco Avatar answered Oct 20 '22 02:10

neilco