bash curl get request raw headers - bash

Hello i'm trying to make the following GET request thru CURL
GET http://localhost:80/ HTTP/1.1
Host: localhost
Proxy-Connection: keep-alive
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16
Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-GB,en-US;q=0.8,en;q=0.6
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
so i try curl -h "Host:localhost" localhost
but it dont work, any ideea where i go wrong here?

It is -H not -h:
curl -H "Host:localhost" localhost

Related

How to make ansible email body break in lines and large font

Hi I have ansible playbook which sends email with attachment. but email body does not come in format all sentences comes in single line and very small font size.
Here is playbook -
- name: Sending an e-mail using the remote machine
mail:
host: localhost
port: 25
from:
to:
subject: Reports
body: Hi,
Hope you are doing well.
Thanks,
Megha
attach:
- file.csv
- file.scv
This gives me output -
Hi,Hope you are doing well.Thanks,Megha
How can I have email body with line breaks and big font size?
You can use html using the parameter subtype: html and your body must have html
- name: Sending an e-mail using the remote machine
mail:
host: localhost
port: 25
from:
to:
subject: Reports
subtype: html
body:
<h1>Hi,</h1>
<p style="color:red">Hope you are doing well.</p>
<strong>Thanks,</strong>
<p style="color:green">Megha</p>
attach:
- file.csv
- file.scv

Disable terminal logs for firebase serve command

Whenever I run firebase serve and loads the firebase site locally, my VSCode terminal fills with lengthy and unnecessary logs like this.
127.0.0.1 - - [29/Nov/2019:21:10:23 +0000] "GET /security HTTP/1.1" 200 10208 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
127.0.0.1 - - [29/Nov/2019:21:10:24 +0000] "GET /assets/css/Features-Boxed.css HTTP/1.1" 200 1075 "http://localhost:5000/security" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
127.0.0.1 - - [29/Nov/2019:21:10:24 +0000] "GET /assets/css/style.css HTTP/1.1" 200 12392 "http://localhost:5000/security" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
127.0.0.1 - - [29/Nov/2019:21:10:24 +0000] "GET /__/firebase/init.js HTTP/1.1" 200 - "http://localhost:5000/security" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
127.0.0.1 - - [29/Nov/2019:21:10:24 +0000] "GET /assets/img/svg/home_white.svg HTTP/1.1" 200 1305 "http://localhost:5000/security" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
127.0.0.1 - - [29/Nov/2019:21:10:24 +0000] "GET /__/firebase/7.5.0/firebase-app.js HTTP/1.1" 200 12066 "http://localhost:5000/security" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
127.0.0.1 - - [29/Nov/2019:21:10:25 +0000] "GET /__/firebase/7.5.0/firebase-analytics.js HTTP/1.1" 200 21623 "http://localhost:5000/security" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
127.0.0.1 - - [29/Nov/2019:21:10:25 +0000] "GET /__/firebase/7.5.0/firebase-auth.js HTTP/1.1" 200 163643 "http://localhost:5000/security" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
127.0.0.1 - - [29/Nov/2019:21:10:25 +0000] "GET /assets/js/main.js HTTP/1.1" 200 5794 "http://localhost:5000/security" "Mozilla/5.0 (Windows
NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
127.0.0.1 - - [29/Nov/2019:21:10:25 +0000] "GET /__/firebase/7.5.0/firebase-app.js.map HTTP/1.1" 200 70975 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
127.0.0.1 - - [29/Nov/2019:21:10:25 +0000] "GET /__/firebase/7.5.0/firebase-analytics.js.map HTTP/1.1" 200 113064 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
127.0.0.1 - - [29/Nov/2019:21:10:25 +0000] "GET /assets/css/style.css.map HTTP/1.1" 200 32580 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
I usually put some console.log statements here and that get lost in all this mess. How to disable it?
Terminal: VSCode built-in Terminal
Project: Firebase web app
Platform: Windows

Websockets request getting 404 on my website - repeated tries on mediawiki pages

This started yesterday morning about 4pm GMT. So far three individual IP addresses. I have anonymized the ip addresses with NNN.
In all three cases, they searched and successfully hit one of my media wiki pages. Two of them got a pattern of 408 errors. Then they started repeat spamming of "websocket" requests - and as far as I know websocket is not implemented on my site. One also reflects Ajax Error CB. One shows "Plugin:ABN".
It would appear that some browser or browser add-in is misbehaving. In one case the initial search was Bing so it could be Windows 10. What is annoying is spamming 2000 websocket requests that get an error 404 on my website over a 6 hour period.
Any ideas on what would cause this? In the last 24 hours these three sites generating about 5000 error 404's on my website:
Apache log:`Case 1 from 76.30.86.NNN - Comcast IP Address in US.
c-76-30-86-NNN.hsd1.tx.comcast.net - - [18/Sep/2019:10:20:22 -0700] "GET /support/kb/Repair/Re-install_Outlook_2003,_2007,_2010,_2013,_2016 HTTP/1.1" 200 10411 "https://www.bing.com/search?q=install+microsoft+outlook&FORM=QSRE4" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.18362"
76.30.86.NNN - - [18/Sep/2019:10:25:24 -0700] "-" 408 137 "-" "-"
76.30.86.NNN - - [18/Sep/2019:10:30:25 -0700] "-" 408 3284 "-" "-"
76.30.86.NNN - - [18/Sep/2019:10:35:25 -0700] "-" 408 3284 "-" "-"
76.30.86.NNN - - [18/Sep/2019:10:40:25 -0700] "-" 408 3284 "-" "-"
76.30.86.NNN - - [18/Sep/2019:10:45:26 -0700] "-" 408 3284 "-" "-"
76.30.86.NNN - - [18/Sep/2019:10:50:26 -0700] "-" 408 3284 "-" "-"
76.30.86.NNN - - [18/Sep/2019:10:55:26 -0700] "-" 408 3284 "-" "-"
76.30.86.NNN - - [18/Sep/2019:11:00:27 -0700] "-" 408 3284 "-" "-"
76.30.86.NNN - - [18/Sep/2019:11:05:27 -0700] "-" 408 3284 "-" "-"
76.30.86.NNN - - [18/Sep/2019:11:10:27 -0700] "-" 408 3284 "-" "-"
76.30.86.NNN - - [18/Sep/2019:11:15:28 -0700] "-" 408 3284 "-" "-"
c-76-30-86-NNN.hsd1.tx.comcast.net - - [18/Sep/2019:11:15:28 -0700] "GET /82A2C3C3-09A7-A741-99A9-2EC607BE97FF/init?url=https%3A%2F%2Fwww.mywebsite.com%2Fsupport%2Fkb%2FRepair%2FRe-install_Outlook_2003%2C_2007%2C_2010%2C_2013%2C_2016&isTopLevel=true&nocache=14f0e HTTP/1.1" 301 4417 "https://www.mywebsite.com/support/kb/Repair/Re-install_Outlook_2003,_2007,_2010,_2013,_2016" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.18362"
c-76-30-86-NNN.hsd1.tx.comcast.net - - [18/Sep/2019:11:15:28 -0700] "GET /82A2C3C3-09A7-A741-99A9-2EC607BE97FF/websocket?url=https%3A%2F%2Fwww.mywebsite.com%2Fsupport%2Fkb%2FRepair%2FRe-install_Outlook_2003%2C_2007%2C_2010%2C_2013%2C_2016&nocache=1568830527710 HTTP/1.1" 301 4336 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.18362"
snip - repeats approx every second for 2040 times
c-76-30-86-NNN.hsd1.tx.comcast.net - - [18/Sep/2019:17:15:57 -0700] "GET /82A2C3C3-09A7-A741-99A9-2EC607BE97FF/init/?url=https%3A%2F%2Fwww.mywebsite.com%2Fsupport%2Fkb%2FRepair%2FRe-install_Outlook_2003%2C_2007%2C_2010%2C_2013%2C_2016&isTopLevel=true&nocache=10fec HTTP/1.1" 404 55891 "https://www.mywebsite.com/support/kb/Repair/Re-install_Outlook_2003,_2007,_2010,_2013,_2016" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.18362"
c-76-30-86-NNN.hsd1.tx.comcast.net - - [18/Sep/2019:17:15:57 -0700] "GET /82A2C3C3-09A7-A741-99A9-2EC607BE97FF/init?url=https%3A%2F%2Fwww.mywebsite.com%2Fsupport%2Fkb%2FRepair%2FRe-install_Outlook_2003%2C_2007%2C_2010%2C_2013%2C_2016&isTopLevel=true&nocache=10fec HTTP/1.1" 301 4417 "https://www.mywebsite.com/support/kb/Repair/Re-install_Outlook_2003,_2007,_2010,_2013,_2016" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.18362"
c-76-30-86-NNN.hsd1.tx.comcast.net - - [18/Sep/2019:18:48:27 -0700] "GET /support/kb/Repair/Re-install_Outlook_2003,_2007,_2010,_2013,_2016 HTTP/1.1" 200 10412 "https://www.bing.com/search?q=install+microsoft+outlook&FORM=QSRE4" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.18362"
c-76-30-86-NNN.hsd1.tx.comcast.net - - [18/Sep/2019:19:44:52 -0700] "GET /support/kb/Repair/Re-install_Outlook_2003,_2007,_2010,_2013,_2016 HTTP/1.1" 200 10413 "https://www.bing.com/search?q=install+microsoft+outlook&FORM=QSRE4" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.18362"
`

Ansible Playbook creating BitBucket Repository

I am trying to create a BitBucket Repository via Ansible Playbook.
However, running the following command using RestAPI works fine:
curl -u user:Password \
-d '#data.json' \
-X POST \
-H "Content-Type: application/json" \
http:// https://api.bitbucket.org/1.0/projects/SUN/repos
JSON includes the following:
{"name": "my-repo",
"scmId": "git",
"forkable": true}
I tried all kind of ways to convert this curl command to an ansible playbook but it`s always failing with different errors.
- hosts: localhost
tasks:
- name: Create a Bitbucket Repo
uri:
url: https://api.bitbucket.org/1.0/projects/SUN/repos
method: POST
user: user
password: password
src: data.json
force_basic_auth: yes
status_code: 201
body_format: json
When leaving "tasks" it says playbook needs to be a list of plays.
When removing tasks it says "uri" is not valid attribute.
Can anyone advise on the structure the playbook should have in this example?
Thanks a lot
The "tasks needs to be a list" message generally means you either
forgot a - (dash) before a task
- hosts: localhost
tasks
name: # no dash here.
uri:
# ...
misindented something.
I Re-formatted your code. It looks OK to me, as reformatted. Double check what you have in your playbook. But you do need the tasks: keyword or you will get the second error message you mention for sure.

Alter Ansible registered variable in place

I'm writing an Ansible role which will update the settings of an existing application configuration. The role must get the settings from the application's API. Alter a portion of the settings. Then POST the complete set back to the application.
- name: Get Current Settings
shell: curl -L -H "Accept: application/json" -u "{{auth}}" https://{{ server }}/api/settings
register: settings
- name: update settings
<Do something to modify settings.stdout as JSON>
register: newSettings # Save
when: settings.Changed = True
- name: Post Settings
shell: curl -L -u "{{auth}}" -X POST -H "Content-Type: application/json" -d {{newSettings}}
I would consider using the URI module of Ansible.
Interacts with HTTP and HTTPS web services and supports Digest, Basic and WSSE HTTP authentication mechanisms.
You can do the first part with a GET:
- uri:
url: http://www.example.com
return_content: yes
register: webpage
Do your data massaging and then do a POST:
- name: Example POST
uri:
url: https://your.example.com/rest/api/2/issue/
method: POST
user: your_username
password: your_pass
body: "{{ lookup('file','issue.json') }}"
force_basic_auth: yes
status_code: 201
body_format: json
Edit:
As was pointed out in the comments you can use set_fact to set the value you change from the information you receive from the GET call.
- set_fact: one_fact="something" other_fact="{{ local_var }}"
Inside your put you would access the new fact like you would any other variable in Ansible

Resources