Make nginx return a JSON header


turret
25/12/2015 9:47 am
HOME ยป Network & Servers

PHP/5.4.45, nginx/1.2.1

My PHP script set correct content/type for json:

header('Content-Type: application/json; charset=UTF-8');

But in server response header:

Content-Type:text/html

How I should change header for this php page?

header function work correctly on apache servers. How to set correct header on nginx?


Related to : Make nginx return a JSON header
Make nginx return a JSON header
25/12/2015 9:47 am Network & Servers

PHP/5.4.45, nginx/1.2.1

My PHP script set correct content/type for json:

header('Content-Type: application/json; charset=UTF-8');

But in server response header:

Content-Type:text/html

How I should change header for this php page?

header function work correctly on apache servers. How to set correct header on nginx?


How to make Rails parse a posted string as json without sending the 'Content-type: application/json' header?
Network & Servers

Rails changes behaviour at several levels when the header 'Content-type: application/json' is sent:


submitted post body is parsed as json instead of just a string parameter
wrap_parameters :format => [:json] in config/initializers/wrap_parameters.rb is used when parsing posted mentioned parameters (so you can either send json with or without a root element)

What if I cannot trust the (external) client in passing the right header? In other words, I want to have my application behave as if the client always passes the 'Content-type: application/json' header, even if the client actually does not?


Annotating resource to produce JSON, but return “text/plain” in response header
Network & Servers

I am currently implementing a web API


Spring
Jersey
com.thetransactioncompany.cors http://software.dzhuvinov.com/cors-filter.html

The output (if any) will be JSON, so all my classes are annotated with the expected media type.


@Produces(MediaType.APPLICATION_JSON)
public class CustomerResource {
...
}

that way my classes are automatically transformed to json.


BUT...


Due to microsoft, their IE only support CORS, if the request/response type is text/plain http://blogs.msdn.com/b/ieinternals/archive/2010/05/13/xdomainrequ

Grails Spring security - Can you change auth responses based on the request header, forward to login page for html req return 401 code for json req
Network & Servers

I have a grails app configured with spring security, when I access via a browser and am not authenticated it redirects me to the login page. If I access a JSON webservice within the app it doesnt give an authentication error as the response it returns the html login page to the client.


Is it possible to define different authentication methods based on if the client is requesting html vs json? i.e. return a response code of 401 if requesting JSON and not authenticated?




HD Wallpapers
3D
3D Abstract
City
Celebrities
Indian Celebrities
Cars
Travel
Girls
Animals Birds
Movies
Sports
Black White
Nature
Planes
Anime
Food Drink
Dreamy Fantasy
Architecture
Games
Space
Holidays
Flowers
Love
Artistic
Baby
Beach
Bikes Motorcycles
Macro
Computers
Vector
Funny
Army
Textures
Brands
Misc
Music
Other
Privacy Policy - Copyrights Notice - Feedback - Report Violation - RSS 2017 © bighow.org All Rights Reserved .