Skip to content

Commit

Permalink
Fix HttpRequest to avoid losing content type
Browse files Browse the repository at this point in the history
When created from a prototype request, the new request is no longer dropping the Content-Type header.

Closes #50
  • Loading branch information
testinfected committed Oct 13, 2016
1 parent 6384484 commit 29052d8
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 50 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,15 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [0.11] -

### Added

### Changed

### Fixed
-

## [0.10] - 2016-06-28
### Added
- Add a cookie session storage mechanism, as an alternative to the in-memory session pool.
Expand Down
97 changes: 48 additions & 49 deletions src/main/java/com/vtence/molecule/http/HeaderNames.java
Expand Up @@ -2,65 +2,64 @@

/**
* HTTP Request and Response Headers (see <a href="https://tools.ietf.org/html/rfc7231">RFC 7231</a>).
*
* Not meant to be implemented, but used as static imports.
*/
public final class HeaderNames {
public interface HeaderNames {
String CONTENT_TYPE = "Content-Type";
String CONTENT_ENCODING = "Content-Encoding";
String CONTENT_LANGUAGE = "Content-Language";
String CONTENT_LOCATION = "Content-Location";

public static final String CONTENT_TYPE = "Content-Type";
public static final String CONTENT_ENCODING = "Content-Encoding";
public static final String CONTENT_LANGUAGE = "Content-Language";
public static final String CONTENT_LOCATION = "Content-Location";
String CONTENT_LENGTH = "Content-Length";
String CONTENT_RANGE = "Content-Range";
String TRAILER = "Trailer";
String TRANSFER_ENCODING = "Transfer-Encoding";

public static final String CONTENT_LENGTH = "Content-Length";
public static final String CONTENT_RANGE = "Content-Range";
public static final String TRAILER = "Trailer";
public static final String TRANSFER_ENCODING = "Transfer-Encoding";
String CACHE_CONTROL = "Cache-Control";
String EXPECT = "Expect";
String HOST = "Host";
String MAX_FORWARDS = "Max-Forwards";
String PRAGMA = "Pragma";
String RANGE = "RANGE";
String TE = "TE";

public static final String CACHE_CONTROL = "Cache-Control";
public static final String EXPECT = "Expect";
public static final String HOST = "Host";
public static final String MAX_FORWARDS = "Max-Forwards";
public static final String PRAGMA = "Pragma";
public static final String RANGE = "RANGE";
public static final String TE = "TE";
String IF_MATCH = "If-Match";
String IF_NONE_MATCH = "If-None-Match";
String IF_MODIFIED_SINCE = "If-Modified-Since";
String IF_UNMODIFIED_SINCE = "If-Unmodified-Since";
String IF_RANGE = "If-Range";

public static final String IF_MATCH = "If-Match";
public static final String IF_NONE_MATCH = "If-None-Match";
public static final String IF_MODIFIED_SINCE = "If-Modified-Since";
public static final String IF_UNMODIFIED_SINCE = "If-Unmodified-Since";
public static final String IF_RANGE = "If-Range";
String ACCEPT = "Accept";
String ACCEPT_CHARSET = "Accept-Charset";
String ACCEPT_ENCODING = "Accept-Encoding";
String ACCEPT_LANGUAGE = "Accept-Language";

public static final String ACCEPT = "Accept";
public static final String ACCEPT_CHARSET = "Accept-Charset";
public static final String ACCEPT_ENCODING = "Accept-Encoding";
public static final String ACCEPT_LANGUAGE = "Accept-Language";
String AUTHORIZATION = "Authorization";
String PROXY_AUTHORIZATION = "Proxy-Authorization";

public static final String AUTHORIZATION = "Authorization";
public static final String PROXY_AUTHORIZATION = "Proxy-Authorization";
String FROM = "From";
String REFERER = "Referer";
String USER_AGENT = "User-Agent";

public static final String FROM = "From";
public static final String REFERER = "Referer";
public static final String USER_AGENT = "User-Agent";
String AGE = "Age";
String EXPIRES = "Expires";
String DATE = "Date";
String LOCATION = "Location";
String RETRY_AFTER = "Retry-After";
String VARY = "Vary";
String WARNING = "Warning";

public static final String AGE = "Age";
public static final String EXPIRES = "Expires";
public static final String DATE = "Date";
public static final String LOCATION = "Location";
public static final String RETRY_AFTER = "Retry-After";
public static final String VARY = "Vary";
public static final String WARNING = "Warning";
String ETAG = "ETag";
String LAST_MODIFIED = "Last-Modified";

public static final String ETAG = "ETag";
public static final String LAST_MODIFIED = "Last-Modified";
String WWW_AUTHENTICATE = "WWW-Authenticate";
String PROXY_AUTHENTICATE = "Proxy-Authenticate";

public static final String WWW_AUTHENTICATE = "WWW-Authenticate";
public static final String PROXY_AUTHENTICATE = "Proxy-Authenticate";
String ACCEPT_RANGES = "Accept-Ranges";
String ALLOW = "Allow";
String SERVER = "Server";

public static final String ACCEPT_RANGES = "Accept-Ranges";
public static final String ALLOW = "Allow";
public static final String SERVER = "Server";

public static final String SET_COOKIE = "Set-Cookie";
public static final String COOKIE = "Cookie";

HeaderNames() {}
String SET_COOKIE = "Set-Cookie";
String COOKIE = "Cookie";
}
Expand Up @@ -132,13 +132,15 @@ public HttpRequest but() {
request.method(method);
request.followRedirects(followRedirects);
request.secure(secure);
request.content(content);

for (String header : headers.names()) {
request.header(header, headers.list(header));
}
for (String cookie : cookies.keySet()) {
request.cookie(cookie, cookies.get(cookie));
}
request.content(content);

return request;
}

Expand Down

0 comments on commit 29052d8

Please sign in to comment.