How to add headers to OkHttp request interceptor?

Finally, I added the headers this way: @Override public Response intercept(Interceptor.Chain chain) throws IOException { Request request = chain.request(); Request newRequest; newRequest = request.newBuilder() .addHeader(HeadersContract.HEADER_AUTHONRIZATION, O_AUTH_AUTHENTICATION) .addHeader(HeadersContract.HEADER_X_CLIENT_ID, CLIENT_ID) .build(); return chain.proceed(newRequest); }

HTTP 401 – what’s an appropriate WWW-Authenticate header value?

When indicating HTTP Basic Authentication we return something like: WWW-Authenticate: Basic realm=”myRealm” Whereas Basic is the scheme and the remainder is very much dependent on that scheme. In this case realm just provides the browser a literal that can be displayed to the user when prompting for the user id and password. You’re obviously not … Read more

Reading header data in Ruby on Rails

request.headers[“Content-Type”] # => “text/plain” replace “Content-Type” with the name of the header that you want to read. Update for Rails 4.2 There are 2 ways to get them in Rails 4.2: Old way (still working): request.headers[“Cookie”] New way: request.headers[“HTTP_COOKIE”] To get a Hash with all headers of the request. request.headers

How to use the CSV MIME-type?

You could try to force the browser to open a “Save As…” dialog by doing something like: header(‘Content-type: text/csv’); header(‘Content-disposition: attachment;filename=MyVerySpecial.csv’); echo “cell 1, cell 2”; Which should work across most major browsers.

Uses of content-disposition in an HTTP response header

Note that RFC 6266 supersedes the RFCs referenced below. Section 7 outlines some of the related security concerns. The authority on the content-disposition header is RFC 1806 and RFC 2183. People have also devised content-disposition hacking. It is important to note that the content-disposition header is not part of the HTTP 1.1 standard. The HTTP … Read more

How can I get all the request headers in Django?

According to the documentation request.META is a “standard Python dictionary containing all available HTTP headers”. If you want to get all the headers you can simply iterate through the dictionary. Which part of your code to do this depends on your exact requirement. Anyplace that has access to request should do. Update I need to … Read more

Paging in a Rest Collection

I don’t really agree with some of you guys. I’ve been working for weeks on this features for my REST service. What I ended up doing is really simple. My solution only makes a sense for what REST people call a collection. Client MUST include a “Range” header to indicate which part of the collection … Read more

Are Duplicate HTTP Response Headers acceptable?

Yes HTTP RFC2616 available here says: Multiple message-header fields with the same field-name MAY be present in a message if and only if the entire field-value for that header field is defined as a comma-separated list [i.e., #(values)]. It MUST be possible to combine the multiple header fields into one “field-name: field-value” pair, without changing … Read more