비전공자 개발일기

WKWebView URL Query & Header Setting 본문

SWIFT

WKWebView URL Query & Header Setting

HiroDaegu 2023. 3. 7. 20:56
728x90
SMALL
let url = "your URL"
var components = URLComponents(string: url)!
components.queryItems = URLQueryItem(name: "name", value: value.trimmingCharacters(in: .whitespaces))
components.queryItems = [URLQueryItem(name: "name1", value: value.trimmingCharacters(in: .whitespaces)), URLQueryItem(name: "name2", value: value.trimmingCharacters(in: .whitespaces))]
var request = URLRequest(url: components.url!)
request.setValue("value", forHTTPHeaderField: "key")

URL Query Setting

URLComponents를 사용하지 않은 경우 https://www.address.com/
URLComponents를 사용하고 URLQueryItem을 1개만 설정한 경우 https://www.address.com/?name=value
URLComponents를 사용하고 URLQueryItem을 2개 이상
설정한 경우
https://www.address.com/?name1=value1&name2=value2&...

URL Header Setting

https://developer.mozilla.org/ko/docs/Web/HTTP/Headers

 

HTTP 헤더 - HTTP | MDN

HTTP 헤더는 클라이언트와 서버가 요청 또는 응답으로 부가적인 정보를 전송할 수 있도록 해줍니다. HTTP 헤더는 대소문자를 구분하지 않는 이름과 콜론 ':' 다음에 오는 값(줄 바꿈 없이)으로 이루

developer.mozilla.org

 

728x90
LIST

'SWIFT' 카테고리의 다른 글

WKWebView OverScroll Disable Setting  (0) 2023.03.15
Swift WKWebView Debugging with Safari  (0) 2023.03.09
SafeArea Color Control  (0) 2023.03.06
WKWebView Reload Code  (0) 2023.03.04
Swift Image Upload to Server(PHP)  (0) 2023.03.03