2. Retrieve Layer Source

In order to get the S2 source of a layer for local editing, a simple GET request is sufficient:

GET /interface/s2/1 HTTP/1.1
Host: www.livejournal.com
Accept: application/x-danga-s2-layer

In addition to the basic header shown above, digest authentication[1] can be used. Anonymous requests are allowed, but the server may respond with 401 Unauthorized, describing the standard HTTP authentication methods supported. Some servers, as described above, may implement “special” authentication methods, such as LiveJournal supporting website session cookies. These are not described (in a machine-readable way, at least) in the Unauthorized response.

Client authors are strongly advised to send the Accept header, as in the future other formats may be supported and the server will be able to see which format you are expecting and either honor your request or return the response Unacceptable if S2 layer source as we know it now is unavailable.

If the response is an error, the response body will contain a short error followed by details of the error, plus optionally further error lines which you may wish to display if they are present. The HTTP response code will give you some idea of the nature of the error.

If the response is successful (response code is 200 OK), and the content-type is application/x-danga-s2-layer, you will find S2 source in the response body. As with error responses, you should consider only ASCII 10 (\n) to mean newline. Disregard ASCII 13 (\r). You may transform the returned \n characters to the local newline representation for output if you wish.