forked from Azure/azure-sdk-for-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Azure#198 from daschult/MakeHttpClientAsync
Make http client async
- Loading branch information
Showing
13 changed files
with
784 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
client-runtime/src/main/java/com/microsoft/rest/v2/http/HttpHeader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for | ||
* license information. | ||
*/ | ||
|
||
package com.microsoft.rest.v2.http; | ||
|
||
/** | ||
* A single header within a HTTP request. If multiple header values are added to a HTTP request with | ||
* the same name (case-insensitive), then the values will be appended to the end of the same Header | ||
* with commas separating them. | ||
*/ | ||
public class HttpHeader { | ||
private final String name; | ||
private String value; | ||
|
||
/** | ||
* Create a new HttpHeader using the provided name and value. | ||
* @param name The name of the HttpHeader. | ||
* @param value The value of the HttpHeader. | ||
*/ | ||
public HttpHeader(String name, String value) { | ||
this.name = name; | ||
this.value = value; | ||
} | ||
|
||
/** | ||
* Get the name of this Header. | ||
* @return The name of this Header. | ||
*/ | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
/** | ||
* Get the value of this Header. | ||
* @return The value of this Header. | ||
*/ | ||
public String getValue() { | ||
return value; | ||
} | ||
|
||
/** | ||
* Add another value to the end of this Header. | ||
* @param value The value to add to the end of this Header. | ||
*/ | ||
public void addValue(String value) { | ||
value += "," + value; | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
client-runtime/src/main/java/com/microsoft/rest/v2/http/HttpHeaders.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for | ||
* license information. | ||
*/ | ||
|
||
package com.microsoft.rest.v2.http; | ||
|
||
import java.util.HashMap; | ||
import java.util.Iterator; | ||
import java.util.Map; | ||
|
||
/** | ||
* A collection of headers that will be applied to a HTTP request. | ||
*/ | ||
public class HttpHeaders implements Iterable<HttpHeader> { | ||
private final Map<String, HttpHeader> headers = new HashMap<>(); | ||
|
||
/** | ||
* Add the provided headerName and headerValue to the list of headers for this request. | ||
* @param headerName The name of the header. | ||
* @param headerValue The value of the header. | ||
* @return This HttpRequest so that multiple operations can be chained together. | ||
*/ | ||
public HttpHeaders add(String headerName, String headerValue) { | ||
final String headerKey = headerName.toLowerCase(); | ||
if (!headers.containsKey(headerKey)) { | ||
headers.put(headerKey, new HttpHeader(headerName, headerValue)); | ||
} | ||
else { | ||
headers.get(headerKey).addValue(headerValue); | ||
} | ||
return this; | ||
} | ||
|
||
@Override | ||
public Iterator<HttpHeader> iterator() { | ||
return headers.values().iterator(); | ||
} | ||
} |
Oops, something went wrong.