Adds a script for turning an html form into a curl requst
This commit is contained in:
		
							parent
							
								
									5638481d1a
								
							
						
					
					
						commit
						a01077a8e9
					
				
					 1 changed files with 26 additions and 0 deletions
				
			
		
							
								
								
									
										26
									
								
								bin/.bin/webtest/formtocurl
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										26
									
								
								bin/.bin/webtest/formtocurl
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,26 @@ | |||
| #!/usr/bin/env bash | ||||
| # Requires hq : https://github.com/coderobe/hq | ||||
| 
 | ||||
| form=$(cat) | ||||
| headers(){ | ||||
| 	echo "$fields" | while read name; do | ||||
| 		value=$(echo "$form" | hq "input[name=$name]" attr value) | ||||
| 		if [ -z "$value" ]; then | ||||
| 			value="<PLACEHOLDER>" | ||||
| 		fi | ||||
| 		echo "-H '${name}=${value}'" | ||||
| 	done | tr '\n' ' ' | sed 's/ $//' | ||||
| } | ||||
| 
 | ||||
| url=$(echo "$form" | hq form attr action) | ||||
| method=$(echo "$form" | hq form attr method) | ||||
| fields=$(echo "$form" | hq input attr name) | ||||
| 
 | ||||
| curlHeaders=$(headers) | ||||
| if [ -z "$method" ]; then | ||||
| 	method="POST" | ||||
| fi | ||||
| 
 | ||||
| echo "curl -X $method $curlHeaders $url" | ||||
| 
 | ||||
| #curlHeaders=$(echo "$fields" | sed 's/\(.*\)/-H '"'"'\1=<PLACEHOLDER>'"'"'/' | tr '\n' ' ') | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue