Commit be66c1c0 authored by Stan Hu's avatar Stan Hu
Browse files

Merge branch 'georgekoltsov/48854-fix-empty-flash-message' into 'master'

Exclude json content type from workhorse interception

See merge request gitlab-org/gitlab-ce!31809
......@@ -116,7 +116,7 @@ def limit_unauthenticated_session_times
def render(*args)
super.tap do
# Set a header for custom error pages to prevent them from being intercepted by gitlab-workhorse
if response.content_type == 'text/html' && (400..599).cover?(response.status)
if (400..599).cover?(response.status) && workhorse_excluded_content_types.include?(response.content_type)
response.headers['X-GitLab-Custom-Error'] = '1'
end
end
......@@ -124,6 +124,10 @@ def render(*args)
protected
def workhorse_excluded_content_types
@workhorse_excluded_content_types ||= %w(text/html application/json)
end
def append_info_to_payload(payload)
super
......
---
title: Fix empty error flash message on profile:account page when updating username
with username that has already been taken
merge_request: 31809
author:
type: fixed
......@@ -641,24 +641,32 @@ def index
end
end
it 'does not set a custom header' do
it 'sets a custom header' do
get :index, format: :json
expect(response.headers['X-GitLab-Custom-Error']).to be_nil
expect(response.headers['X-GitLab-Custom-Error']).to eq '1'
end
end
context 'given a json response for an html request' do
controller do
def index
render json: {}, status: :unprocessable_entity
context 'for html request' do
it 'sets a custom header' do
get :index
expect(response.headers['X-GitLab-Custom-Error']).to eq '1'
end
end
it 'does not set a custom header' do
get :index
context 'for 200 response' do
controller do
def index
render json: {}, status: :ok
end
end
expect(response.headers['X-GitLab-Custom-Error']).to be_nil
it 'does not set a custom header' do
get :index, format: :json
expect(response.headers['X-GitLab-Custom-Error']).to be_nil
end
end
end
end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment