Skip to content
This repository has been archived by the owner on Dec 26, 2020. It is now read-only.

missing required Host header #33

Open
cpdw840624 opened this issue Apr 23, 2019 · 2 comments
Open

missing required Host header #33

cpdw840624 opened this issue Apr 23, 2019 · 2 comments

Comments

@cpdw840624
Copy link

cpdw840624 commented Apr 23, 2019

I use glot-run.Send post request like this:
curl --request POST
--header 'Authorization: Token 0123456-789a-bcde-f012-3456789abcde'
--header 'Content-type: application/json'
--data '{"files": [{"name": "main.py", "content": "print(42)"}]}'
--url 'https://ip:port/languages/python/latest'
then the log shows:
10:31:35.028 [error] gen_fsm <0.636.0> in state recv_http terminated with reason: no function clause matching docker_attach:recv_http(<<"HTTP/1.1 400 Bad Request: missing required Host header\r\n">>, {state,#Port<0.975>,{<0.635.0>,#Ref<0.0.1.525>},[],118}) line 55 10:31:35.028 [error] CRASH REPORT Process <0.636.0> with 0 neighbours exited with reason: no function clause matching docker_attach:recv_http(<<"HTTP/1.1 400 Bad Request: missing required Host header\r\n">>, {state,#Port<0.975>,{<0.635.0>,#Ref<0.0.1.525>},[],118}) line 55 in gen_fsm:terminate/7 line 626 10:31:35.029 [error] Supervisor docker_attach_sup had child docker_attach started with {docker_attach,start_link,undefined} at <0.636.0> exit with reason no function clause matching docker_attach:recv_http(<<"HTTP/1.1 400 Bad Request: missing required Host header\r\n">>, {state,#Port<0.975>,{<0.635.0>,#Ref<0.0.1.525>},[],118}) line 55 in context child_terminated 10:31:35.030 [error] Ranch listener http had connection process started with cowboy_protocol:start_link/4 at <0.635.0> exit with reason: [{reason,{{function_clause,[{docker_attach,recv_http,[<<"HTTP/1.1 400 Bad Request: missing required Host header\r\n">>,{state,#Port<0.975>,{<0.635.0>,#Ref<0.0.1.525>},[],118}],[{file,"/glot-run/_build/default/lib/glot/src/docker/docker_attach.erl"},{line,55}]},{gen_fsm,handle_msg,7,[{file,"gen_fsm.erl"},{line,518}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,240}]}]},{gen_fsm,sync_send_event,[<0.636.0>,{attach,<<"7bf9e233a6bd04261095f8cf30ed8b873ccbaf645712f48975d9f6ef0944333a">>},3600000]}}},{mfa,{language_run_resource,accept_post,2}},{stacktrace,[{gen_fsm,sync_send_event,3,[{file,"gen_fsm.erl"},{line,231}]},{docker,container_attach,1,[{file,"/glot-run/_build/default/lib/glot/src/docker/docker.erl"},{line,47}]},{language_run,run,3,[{file,"/glot-run/_build/default/lib/glot/src/models/language_run.erl"},{line,16}]},{language_run_resource,run_code,3,[{file,"/glot-run/_build/default/lib/glot/src/resources/language_run_resource.erl"},{line,97}]},{cowboy_rest,call,3,[{file,"/glot-run/_build/default/lib/cowboy/src/cowboy_rest.erl"},{line,976}]},{cowboy_rest,process_content_type,3,[{file,"/glot-run/_build/default/lib/cowboy/src/cowboy_rest.erl"},{line,777}]},{cowboy_protocol,execute,4,[{file,"/glot-run/_build/default/lib/cowboy/src/cowboy_protocol.erl"},{line,442}]}]},{req,[{socket,#Port<0.974>},{transport,ranch_tcp},{connection,keepalive},{pid,<0.635.0>},{method,<<"POST">>},{version,'HTTP/1.1'},{peer,{{172,17,0,1},41216}},{host,<<"192.168.3.23">>},{host_info,undefined},{port,9090},{path,<<"/languages/python/latest">>},{path_info,undefined},{qs,<<>>},{qs_vals,undefined},{bindings,[{version,<<"latest">>},{name,<<"python">>}]},{headers,[{<<"user-agent">>,<<"curl/7.29.0">>},{<<"host">>,<<"192.168.3.23:9090">>},{<<"accept">>,<<"*/*">>},{<<"authorization">>,<<"Token d11088bc-a29d-4d49-a633-b1b1ae807064">>},{<<"content-type">>,<<"application/json">>},{<<"content-length">>,<<"56">>}]},{p_headers,[{<<"content-type">>,{<<"application">>,<<"json">>,[]}},{<<"if-modified-since">>,undefined},{<<"if-none-match">>,undefined},{<<"if-unmodified-since">>,undefined},{<<"if-match">>,undefined},{<<"accept">>,[{{<<"*">>,<<"*">>,[]},1000,[]}]}]},{cookies,undefined},{meta,[{media_type,{<<"application">>,<<"json">>,[]}},{charset,undefined}]},{body_state,waiting},{buffer,<<"{\"files\": [{\"name\": \"main.py\", \"content\": \"print(42)\"}]}">>},{multipart,undefined},{resp_compress,false},{resp_state,waiting},{resp_headers,[{<<"content-type">>,[<<"application">>,<<"/">>,<<"json">>,<<>>]}]},{resp_body,<<>>},{onresponse,#Fun<http_util.log_response.4>}]},{state,{state,<<"python">>,<<"latest">>}}]

event log like this:
image

why?

@vsvvssrao
Copy link

Is this error resolved ?? @cpdw840624

@prasmussen,

I am also facing the simlilar kind of issue and following is the error log when i ran the python and following is the error log.
Screenshot 2020-06-18 at 1 06 02 PM

It would be helpful if what the exactly happening and how to resovle this.

@prasmussen
Copy link
Owner

Newer versions of docker requires the Host header to be sent in. This is fixed in newer versions of glot-run. The docker image found on docker hub contains an old version of glot-run.

I would recommend compiling the project from source, the make_release.sh can be used for that.
Note that it won't compile with newer versions of erlang, personally I'm building and hosting the project on Ubuntu 16.04 which has working versions of the packages.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants