Skip Menu |

This queue is for tickets about the Artifactory-Client CPAN distribution.

Report information
The Basics
Id: 97772
Status: resolved
Priority: 0/
Queue: Artifactory-Client

People
Owner: Nobody in particular
Requestors:
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: v0.0.11
Fixed in: (no value)



Subject: zero length file uploads
first off, thank you & I appreciate the module's existance. if you don't already have an artifactory; it is quick to download the latest open source edition of artifactory. http://www.jfrog.com/home/v_artifactory_opensource_download (I used 3.3.0 simply running bin/artifactory.bat) run it; login as admin and create a 'dave-snapshot-local' repo; install Artifactory::Client; and these 2 scripts together should upload and download itself (whatever you call main package) to dave-snapshot-local @ test/foo Or, you know update the urls and repo names to match your test. main script and AgentP.pm for user authentication against the "Artifactory Realm" seems to work fine, the artifact is created but 0 length. On one machine I tested it would give me a time out response from the server. On this Strawberry v5.18.2 multi-x64 I get a created 201 response, quick but zero length file. I know that ultimately this is a: https://metacpan.org/pod/HTTP::Request::StreamingUpload issue, but HTTP::Request-StreamingUpload already has a ticket which describes something that didn't resolve the issue for me. https://rt.cpan.org/Ticket/Display.html?id=68609 Maybe it is related to: https://metacpan.org/pod/HTTP::Request or something else; idk. I haven't gotten out the wireshark and begun spelunking...yet. I figure; we should at least have a ticket on Artifactory-Client to help bring attention to this issue. Thanks. -mrhorner http://dave.thehorners.com/tech-talk/random-tech/522-great-lodge-of-the-royal-order-of-yaks-yak-shaving ====code=== package AgentP; use base 'LWP::UserAgent'; sub _agent { "Mozilla/8.0" } sub get_basic_credentials { my ($self, $realm, $uri) = @_; print( STDERR " - providing auth to realm \"$realm\"\n" ); return 'admin', 'password'; } 1 package main; use Artifactory::Client; use autodie; use Data::Printer; use AgentP; my $ua=AgentP->new(); my $args = { artifactory => 'http://localhost', port => 8081, repository => 'dave-snapshot-local/', ua =>$ua }; p $ua; my $client = Artifactory::Client->new( $args ); p $client; my $path = 'test/foo'; # path on artifactory # Properties are a hashref of key-arrayref pairs. Note that value must be an arrayref even for a single element. # This is to conform with Artifactory which treats property values as a list. my $properties = { one => ['two'], baz => ['three'], }; use File::Spec; my $file=File::Spec->rel2abs( __FILE__ ); #my $file = 'D:\\working\\perl\\testArtifactory-Client.pl'; p $file; $filesize=-s $file; p $filesize; # Name of methods are taken straight from Artifactory REST API documentation. 'Deploy Artifact' would map to # deploy_artifact method, like below. The caller gets HTTP::Response object back. my $resp = $client->deploy_artifact( path => $path, properties => $properties, file => $file ); p $resp; # Custom requests can also be made via usual get / post / put / delete requests. my $resp = $client->get( 'http://localhost:8081/artifactory/dave-snapshot-local/test/foo' ); p $resp; =============OUTPUT FROM MY TEST (your byte count may vary)====== D:\working\perl>perl testArtifactory-Client.pl AgentP { Parents LWP::UserAgent public methods (1) : get_basic_credentials private methods (1) : _agent internals: { def_headers HTTP::Headers, handlers { response_header HTTP::Config }, local_address undef, max_redirect 7, max_size undef, no_proxy [], protocols_allowed undef, protocols_forbidden undef, proxy {}, requests_redirectable [ [0] "GET", [1] "HEAD" ], show_progress undef, ssl_opts { verify_hostname 1 }, timeout 180, use_eval 1 } } Artifactory::Client { Parents Moose::Object public methods (101) : all_builds, archive_entry_download, archive_entry_search, artifact_latest_version_search_based_on_layout, artifact_latest_version_search_based_on_properties, artifact_search, artifact_version_search, artifactory, artifacts_created_in_date_range, artifacts_not_downloaded_since, bad_checksum_search, build_artifacts_search, build_info, build_promotion, build_rename, build_runs, builds_diff, builds_for_dependency, calculate_maven_index, calculate_maven_metadata, calculate_nuget_repository_metadata, calculate_yum_repository_metadata, checksum_search, copy_item, create_directory, create_or_replace_group, create_or_replace_permission_target, create_or_replace_repository_configuration, create_or_replace_user, delete, delete_build, delete_group, delete_item, delete_item_properties, delete_permission_target, delete_repository, delete_repository_replication_configuration, delete_user, deploy_artifact, deploy_artifact_by_checksum, deploy_artifacts_from_archive, DESTROY, effective_item_permissions, execute_build_promotion, execute_plugin_code, export_system, export_system_settings_example, file_compliance_info, file_info, file_list, file_statistics, folder_info, full_system_import, gavc_search, general_configuration, get, get_group_details, get_groups, get_permission_target_details, get_permission_targets, get_repositories, get_repository_replication_configuration, get_user_details, get_users, import_repository_content, import_system_settings_example, item_last_modified, item_properties, license_search, meta, move_item, new, pattern_search, port, post, property_search, pull_push_replication, put, repository, repository_configuration, request, retrieve_all_available_plugin_info, retrieve_artifact, retrieve_build_artifacts_archive, retrieve_build_staging_strategy, retrieve_latest_artifact, retrieve_plugin_info_of_a_certain_type, save_general_configuration, scheduled_replication_status, security_configuration, set_item_properties, set_repository_replication_configuration, system_health_ping, system_info, trace_artifact_retrieval, ua, update_group, update_repository_configuration, update_repository_replication_configuration, update_user, version_and_addons_information private methods (18) : _attach_properties, _build_ua, _get_build, _handle_item, _handle_matrix_props, _handle_non_matrix_props, _handle_plugins, _handle_prop_multivalue, _handle_repositories, _handle_repository_replication_configuration, _handle_search, _handle_search_props, _handle_security, _handle_system, _handle_system_settings, _request, _stringify_hash, _unpack_attributes internals: { artifactory "http://localhost", port 8081, repository "dave-snapshot-local/", ua AgentP } } "D:\working\perl\testArtifactory-Client.pl" 1380 - providing auth to realm "Artifactory Realm" HTTP::Response { Parents HTTP::Message public methods (22) : as_string, base, clone, code, current_age, dump, error_as_HTML, filename, fresh_until, freshness_lifetime, is_error, is_fresh, is_info, is_redirect, is_success, message, new, parse, previous, redirects, request, status_line private methods (0) internals: { _content "{ "repo" : "dave-snapshot-local", "path" : "/test/foo", "created" : "2014-08-05T23:51:30.551-04:00", "createdBy" : "admin", "downloadUri" : "http://localhost:8081/artifactory/dave-snapshot-local/test/foo", "mimeType" : "application/octet-stream", "size" : "0", "checksums" : { "sha1" : "da39a3ee5e6b4b0d3255bfef95601890afd80709", "md5" : "d41d8cd98f00b204e9800998ecf8427e" }, "originalChecksums" : { }, "uri" : "http://localhost:8081/artifactory/dave-snapshot-local/test/foo" }", _headers HTTP::Headers, _msg "Created", _previous HTTP::Response, _protocol "HTTP/1.1", _rc 201, _request HTTP::Request } } HTTP::Response { Parents HTTP::Message public methods (22) : as_string, base, clone, code, current_age, dump, error_as_HTML, filename, fresh_until, freshness_lifetime, is_error, is_fresh, is_info, is_redirect, is_success, message, new, parse, previous, redirects, request, status_line private methods (0) internals: { _content "", _headers HTTP::Headers, _msg "OK", _protocol "HTTP/1.1", _rc 200, _request HTTP::Request } }
Subject: AgentP.pm
package AgentP; use base 'LWP::UserAgent'; sub _agent { "Mozilla/8.0" } sub get_basic_credentials { my ($self, $realm, $uri) = @_; print( STDERR " - providing auth to realm \"$realm\"\n" ); return 'admin', 'password'; } 1
Subject: testArtifactory-Client.pl
use Artifactory::Client; use autodie; use Data::Printer; use AgentP; my $ua=AgentP->new(); my $args = { artifactory => 'http://localhost', port => 8081, repository => 'dave-snapshot-local/', ua =>$ua }; p $ua; my $client = Artifactory::Client->new( $args ); p $client; my $path = 'test/foo'; # path on artifactory # Properties are a hashref of key-arrayref pairs. Note that value must be an arrayref even for a single element. # This is to conform with Artifactory which treats property values as a list. my $properties = { one => ['two'], baz => ['three'], }; use File::Spec; my $file=File::Spec->rel2abs( __FILE__ ); #my $file = 'D:\\working\\perl\\testArtifactory-Client.pl'; p $file; $filesize=-s $file; p $filesize; # Name of methods are taken straight from Artifactory REST API documentation. 'Deploy Artifact' would map to # deploy_artifact method, like below. The caller gets HTTP::Response object back. my $resp = $client->deploy_artifact( path => $path, properties => $properties, file => $file ); p $resp; # Custom requests can also be made via usual get / post / put / delete requests. my $resp = $client->get( 'http://localhost:8081/artifactory/dave-snapshot-local/test/foo' ); p $resp;
mrhorner, Thanks for bringing this issue to my attention. I have do have a free version of Artifactory on my local Linux box to test with, so I will see if I can reproduce the issue you're observing. On Wed Aug 06 00:41:53 2014, MRHORNER wrote: Show quoted text
> first off, thank you & I appreciate the module's existance. > > if you don't already have an artifactory; it is quick to download the > latest open source edition of artifactory. > http://www.jfrog.com/home/v_artifactory_opensource_download (I used > 3.3.0 simply running bin/artifactory.bat) > run it; login as admin and create a 'dave-snapshot-local' repo; > install Artifactory::Client; and these 2 scripts together should > upload and download itself (whatever you call main package) to dave- > snapshot-local @ test/foo > Or, you know update the urls and repo names to match your test. > > main script and AgentP.pm for user authentication against the > "Artifactory Realm" seems to work fine, the artifact is created but 0 > length. > On one machine I tested it would give me a time out response from the > server. On this Strawberry v5.18.2 multi-x64 I get a created 201 > response, quick but zero length file. > > I know that ultimately this is a: > https://metacpan.org/pod/HTTP::Request::StreamingUpload > issue, but HTTP::Request-StreamingUpload already has a ticket which > describes something that didn't resolve the issue for me. > https://rt.cpan.org/Ticket/Display.html?id=68609 > > Maybe it is related to: > https://metacpan.org/pod/HTTP::Request > or something else; idk. I haven't gotten out the wireshark and begun > spelunking...yet. > > I figure; we should at least have a ticket on Artifactory-Client to > help bring attention to this issue. > > Thanks. > -mrhorner > http://dave.thehorners.com/tech-talk/random-tech/522-great-lodge-of- > the-royal-order-of-yaks-yak-shaving > > ====code=== > package AgentP; > use base 'LWP::UserAgent'; > sub _agent { "Mozilla/8.0" } > sub get_basic_credentials { > my ($self, $realm, $uri) = @_; > print( STDERR " - providing auth to realm \"$realm\"\n" ); > return 'admin', 'password'; > } > > 1 > > package main; > > use Artifactory::Client; > use autodie; > use Data::Printer; > use AgentP; > my $ua=AgentP->new(); > my $args = { > artifactory => 'http://localhost', > port => 8081, > repository => 'dave-snapshot-local/', > ua =>$ua > }; > p $ua; > my $client = Artifactory::Client->new( $args ); > p $client; > my $path = 'test/foo'; # path on artifactory > > # Properties are a hashref of key-arrayref pairs. Note that value > must be an arrayref even for a single element. > # This is to conform with Artifactory which treats property values as > a list. > my $properties = { > one => ['two'], > baz => ['three'], > }; > > use File::Spec; > my $file=File::Spec->rel2abs( __FILE__ ); > #my $file = 'D:\\working\\perl\\testArtifactory-Client.pl'; > p $file; > $filesize=-s $file; > p $filesize; > # Name of methods are taken straight from Artifactory REST API > documentation. 'Deploy Artifact' would map to > # deploy_artifact method, like below. The caller gets HTTP::Response > object back. > my $resp = $client->deploy_artifact( path => $path, properties => > $properties, file => $file ); > p $resp; > > # Custom requests can also be made via usual get / post / put / delete > requests. > my $resp = $client->get( 'http://localhost:8081/artifactory/dave- > snapshot-local/test/foo' ); > p $resp; > > =============OUTPUT FROM MY TEST (your byte count may vary)====== > D:\working\perl>perl testArtifactory-Client.pl > AgentP { > Parents LWP::UserAgent > public methods (1) : get_basic_credentials > private methods (1) : _agent > internals: { > def_headers HTTP::Headers, > handlers { > response_header HTTP::Config > }, > local_address undef, > max_redirect 7, > max_size undef, > no_proxy [], > protocols_allowed undef, > protocols_forbidden undef, > proxy {}, > requests_redirectable [ > [0] "GET", > [1] "HEAD" > ], > show_progress undef, > ssl_opts { > verify_hostname 1 > }, > timeout 180, > use_eval 1 > } > } > Artifactory::Client { > Parents Moose::Object > public methods (101) : all_builds, archive_entry_download, > archive_entry_search, artifact_latest_version_search_based_on_layout, > artifact_latest_version_search_based_on_properties, artifact_search, > artifact_version_search, artifactory, artifacts_created_in_date_range, > artifacts_not_downloaded_since, bad_checksum_search, > build_artifacts_search, build_info, build_promotion, build_rename, > build_runs, builds_diff, builds_for_dependency, calculate_maven_index, > calculate_maven_metadata, calculate_nuget_repository_metadata, > calculate_yum_repository_metadata, checksum_search, copy_item, > create_directory, create_or_replace_group, > create_or_replace_permission_target, > create_or_replace_repository_configuration, create_or_replace_user, > delete, delete_build, delete_group, delete_item, > delete_item_properties, delete_permission_target, delete_repository, > delete_repository_replication_configuration, delete_user, > deploy_artifact, deploy_artifact_by_checksum, > deploy_artifacts_from_archive, DESTROY, effective_item_permissions, > execute_build_promotion, execute_plugin_code, export_system, > export_system_settings_example, file_compliance_info, file_info, > file_list, file_statistics, folder_info, full_system_import, > gavc_search, general_configuration, get, get_group_details, > get_groups, get_permission_target_details, get_permission_targets, > get_repositories, get_repository_replication_configuration, > get_user_details, get_users, import_repository_content, > import_system_settings_example, item_last_modified, item_properties, > license_search, meta, move_item, new, pattern_search, port, post, > property_search, pull_push_replication, put, repository, > repository_configuration, request, retrieve_all_available_plugin_info, > retrieve_artifact, retrieve_build_artifacts_archive, > retrieve_build_staging_strategy, retrieve_latest_artifact, > retrieve_plugin_info_of_a_certain_type, save_general_configuration, > scheduled_replication_status, security_configuration, > set_item_properties, set_repository_replication_configuration, > system_health_ping, system_info, trace_artifact_retrieval, ua, > update_group, update_repository_configuration, > update_repository_replication_configuration, update_user, > version_and_addons_information > private methods (18) : _attach_properties, _build_ua, _get_build, > _handle_item, _handle_matrix_props, _handle_non_matrix_props, > _handle_plugins, _handle_prop_multivalue, _handle_repositories, > _handle_repository_replication_configuration, _handle_search, > _handle_search_props, _handle_security, _handle_system, > _handle_system_settings, _request, _stringify_hash, _unpack_attributes > internals: { > artifactory "http://localhost", > port 8081, > repository "dave-snapshot-local/", > ua AgentP > } > } > "D:\working\perl\testArtifactory-Client.pl" > 1380 > - providing auth to realm "Artifactory Realm" > HTTP::Response { > Parents HTTP::Message > public methods (22) : as_string, base, clone, code, current_age, > dump, error_as_HTML, filename, fresh_until, freshness_lifetime, > is_error, is_fresh, is_info, is_redirect, is_success, message, new, > parse, previous, redirects, request, status_line > private methods (0) > internals: { > _content "{ > "repo" : "dave-snapshot-local", > "path" : "/test/foo", > "created" : "2014-08-05T23:51:30.551-04:00", > "createdBy" : "admin", > "downloadUri" : "http://localhost:8081/artifactory/dave-snapshot- > local/test/foo", > "mimeType" : "application/octet-stream", > "size" : "0", > "checksums" : { > "sha1" : "da39a3ee5e6b4b0d3255bfef95601890afd80709", > "md5" : "d41d8cd98f00b204e9800998ecf8427e" > }, > "originalChecksums" : { > }, > "uri" : "http://localhost:8081/artifactory/dave-snapshot- > local/test/foo" > }", > _headers HTTP::Headers, > _msg "Created", > _previous HTTP::Response, > _protocol "HTTP/1.1", > _rc 201, > _request HTTP::Request > } > } > HTTP::Response { > Parents HTTP::Message > public methods (22) : as_string, base, clone, code, current_age, > dump, error_as_HTML, filename, fresh_until, freshness_lifetime, > is_error, is_fresh, is_info, is_redirect, is_success, message, new, > parse, previous, redirects, request, status_line > private methods (0) > internals: { > _content "", > _headers HTTP::Headers, > _msg "OK", > _protocol "HTTP/1.1", > _rc 200, > _request HTTP::Request > } > }
I downloaded your scripts, made some changes then ran them; it seems to work just fine. "repo" : "dave-snapshot-local", "path" : "/test/foo", "created" : "2014-08-11T22:32:34.355-07:00", "createdBy" : "anonymous", "downloadUri" : "http://localhost:8081/artifactory/dave-snapshot-local/test/foo", "mimeType" : "application/octet-stream", "size" : "874", I'm attaching the exact files I've used for my testing. Could you give them a spin and see how well they fare on your environment? My environment runs Fedora 20 and I have local Artifactory running with very basic set up. We have to figure out something if this issue requires HTTP basic authentication set up in order to reproduce the issue. On Mon Aug 11 23:19:59 2014, SYAGI wrote: Show quoted text
> mrhorner, > > Thanks for bringing this issue to my attention. I have do have a free > version of Artifactory on my local Linux box to test with, so I will > see if I can reproduce the issue you're observing. > > On Wed Aug 06 00:41:53 2014, MRHORNER wrote:
> > first off, thank you & I appreciate the module's existance. > > > > if you don't already have an artifactory; it is quick to download the > > latest open source edition of artifactory. > > http://www.jfrog.com/home/v_artifactory_opensource_download (I used > > 3.3.0 simply running bin/artifactory.bat) > > run it; login as admin and create a 'dave-snapshot-local' repo; > > install Artifactory::Client; and these 2 scripts together should > > upload and download itself (whatever you call main package) to dave- > > snapshot-local @ test/foo > > Or, you know update the urls and repo names to match your test. > > > > main script and AgentP.pm for user authentication against the > > "Artifactory Realm" seems to work fine, the artifact is created but 0 > > length. > > On one machine I tested it would give me a time out response from the > > server. On this Strawberry v5.18.2 multi-x64 I get a created 201 > > response, quick but zero length file. > > > > I know that ultimately this is a: > > https://metacpan.org/pod/HTTP::Request::StreamingUpload > > issue, but HTTP::Request-StreamingUpload already has a ticket which > > describes something that didn't resolve the issue for me. > > https://rt.cpan.org/Ticket/Display.html?id=68609 > > > > Maybe it is related to: > > https://metacpan.org/pod/HTTP::Request > > or something else; idk. I haven't gotten out the wireshark and begun > > spelunking...yet. > > > > I figure; we should at least have a ticket on Artifactory-Client to > > help bring attention to this issue. > > > > Thanks. > > -mrhorner > > http://dave.thehorners.com/tech-talk/random-tech/522-great-lodge-of- > > the-royal-order-of-yaks-yak-shaving > > > > ====code=== > > package AgentP; > > use base 'LWP::UserAgent'; > > sub _agent { "Mozilla/8.0" } > > sub get_basic_credentials { > > my ($self, $realm, $uri) = @_; > > print( STDERR " - providing auth to realm \"$realm\"\n" ); > > return 'admin', 'password'; > > } > > > > 1 > > > > package main; > > > > use Artifactory::Client; > > use autodie; > > use Data::Printer; > > use AgentP; > > my $ua=AgentP->new(); > > my $args = { > > artifactory => 'http://localhost', > > port => 8081, > > repository => 'dave-snapshot-local/', > > ua =>$ua > > }; > > p $ua; > > my $client = Artifactory::Client->new( $args ); > > p $client; > > my $path = 'test/foo'; # path on artifactory > > > > # Properties are a hashref of key-arrayref pairs. Note that value > > must be an arrayref even for a single element. > > # This is to conform with Artifactory which treats property values as > > a list. > > my $properties = { > > one => ['two'], > > baz => ['three'], > > }; > > > > use File::Spec; > > my $file=File::Spec->rel2abs( __FILE__ ); > > #my $file = 'D:\\working\\perl\\testArtifactory-Client.pl'; > > p $file; > > $filesize=-s $file; > > p $filesize; > > # Name of methods are taken straight from Artifactory REST API > > documentation. 'Deploy Artifact' would map to > > # deploy_artifact method, like below. The caller gets HTTP::Response > > object back. > > my $resp = $client->deploy_artifact( path => $path, properties => > > $properties, file => $file ); > > p $resp; > > > > # Custom requests can also be made via usual get / post / put / > > delete > > requests. > > my $resp = $client->get( 'http://localhost:8081/artifactory/dave- > > snapshot-local/test/foo' ); > > p $resp; > > > > =============OUTPUT FROM MY TEST (your byte count may vary)====== > > D:\working\perl>perl testArtifactory-Client.pl > > AgentP { > > Parents LWP::UserAgent > > public methods (1) : get_basic_credentials > > private methods (1) : _agent > > internals: { > > def_headers HTTP::Headers, > > handlers { > > response_header HTTP::Config > > }, > > local_address undef, > > max_redirect 7, > > max_size undef, > > no_proxy [], > > protocols_allowed undef, > > protocols_forbidden undef, > > proxy {}, > > requests_redirectable [ > > [0] "GET", > > [1] "HEAD" > > ], > > show_progress undef, > > ssl_opts { > > verify_hostname 1 > > }, > > timeout 180, > > use_eval 1 > > } > > } > > Artifactory::Client { > > Parents Moose::Object > > public methods (101) : all_builds, archive_entry_download, > > archive_entry_search, artifact_latest_version_search_based_on_layout, > > artifact_latest_version_search_based_on_properties, artifact_search, > > artifact_version_search, artifactory, > > artifacts_created_in_date_range, > > artifacts_not_downloaded_since, bad_checksum_search, > > build_artifacts_search, build_info, build_promotion, build_rename, > > build_runs, builds_diff, builds_for_dependency, > > calculate_maven_index, > > calculate_maven_metadata, calculate_nuget_repository_metadata, > > calculate_yum_repository_metadata, checksum_search, copy_item, > > create_directory, create_or_replace_group, > > create_or_replace_permission_target, > > create_or_replace_repository_configuration, create_or_replace_user, > > delete, delete_build, delete_group, delete_item, > > delete_item_properties, delete_permission_target, delete_repository, > > delete_repository_replication_configuration, delete_user, > > deploy_artifact, deploy_artifact_by_checksum, > > deploy_artifacts_from_archive, DESTROY, effective_item_permissions, > > execute_build_promotion, execute_plugin_code, export_system, > > export_system_settings_example, file_compliance_info, file_info, > > file_list, file_statistics, folder_info, full_system_import, > > gavc_search, general_configuration, get, get_group_details, > > get_groups, get_permission_target_details, get_permission_targets, > > get_repositories, get_repository_replication_configuration, > > get_user_details, get_users, import_repository_content, > > import_system_settings_example, item_last_modified, item_properties, > > license_search, meta, move_item, new, pattern_search, port, post, > > property_search, pull_push_replication, put, repository, > > repository_configuration, request, > > retrieve_all_available_plugin_info, > > retrieve_artifact, retrieve_build_artifacts_archive, > > retrieve_build_staging_strategy, retrieve_latest_artifact, > > retrieve_plugin_info_of_a_certain_type, save_general_configuration, > > scheduled_replication_status, security_configuration, > > set_item_properties, set_repository_replication_configuration, > > system_health_ping, system_info, trace_artifact_retrieval, ua, > > update_group, update_repository_configuration, > > update_repository_replication_configuration, update_user, > > version_and_addons_information > > private methods (18) : _attach_properties, _build_ua, _get_build, > > _handle_item, _handle_matrix_props, _handle_non_matrix_props, > > _handle_plugins, _handle_prop_multivalue, _handle_repositories, > > _handle_repository_replication_configuration, _handle_search, > > _handle_search_props, _handle_security, _handle_system, > > _handle_system_settings, _request, _stringify_hash, > > _unpack_attributes > > internals: { > > artifactory "http://localhost", > > port 8081, > > repository "dave-snapshot-local/", > > ua AgentP > > } > > } > > "D:\working\perl\testArtifactory-Client.pl" > > 1380 > > - providing auth to realm "Artifactory Realm" > > HTTP::Response { > > Parents HTTP::Message > > public methods (22) : as_string, base, clone, code, current_age, > > dump, error_as_HTML, filename, fresh_until, freshness_lifetime, > > is_error, is_fresh, is_info, is_redirect, is_success, message, new, > > parse, previous, redirects, request, status_line > > private methods (0) > > internals: { > > _content "{ > > "repo" : "dave-snapshot-local", > > "path" : "/test/foo", > > "created" : "2014-08-05T23:51:30.551-04:00", > > "createdBy" : "admin", > > "downloadUri" : "http://localhost:8081/artifactory/dave-snapshot- > > local/test/foo", > > "mimeType" : "application/octet-stream", > > "size" : "0", > > "checksums" : { > > "sha1" : "da39a3ee5e6b4b0d3255bfef95601890afd80709", > > "md5" : "d41d8cd98f00b204e9800998ecf8427e" > > }, > > "originalChecksums" : { > > }, > > "uri" : "http://localhost:8081/artifactory/dave-snapshot- > > local/test/foo" > > }", > > _headers HTTP::Headers, > > _msg "Created", > > _previous HTTP::Response, > > _protocol "HTTP/1.1", > > _rc 201, > > _request HTTP::Request > > } > > } > > HTTP::Response { > > Parents HTTP::Message > > public methods (22) : as_string, base, clone, code, current_age, > > dump, error_as_HTML, filename, fresh_until, freshness_lifetime, > > is_error, is_fresh, is_info, is_redirect, is_success, message, new, > > parse, previous, redirects, request, status_line > > private methods (0) > > internals: { > > _content "", > > _headers HTTP::Headers, > > _msg "OK", > > _protocol "HTTP/1.1", > > _rc 200, > > _request HTTP::Request > > } > > }
Subject: test.zip
Download test.zip
application/zip 942b

Message body not shown because it is not plain text.

Message body is not shown because it is too large.

I have a webserver at workplace, with HTTP Basic auth and here is my code to get passed the credential business: my $h = HTTP::Headers->new(); $h->authorization_basic( 'user', 'pass' ); my $ua = LWP::UserAgent->new( default_headers => $h ); my $resp = $ua->get($url); See if that helps. My use case is read-only, but I don't have to do Base64 conversion and all that complex stuff. Does Artifactory Server support Basic HTTP Auth, or do you have a proxy node providing the authentication service between the client and Artifactory? On Fri Aug 15 23:14:52 2014, MRHORNER wrote: Show quoted text
> The code provided shows a 401 Unauthorized and 0 length file again. I > saw that you dropped the () from the return of the > get_basic_credentials... I also tried supplying the header=> > HTTP::Headers->new( > 'Content-Type'=>'application/binary', > 'Content-Length'=> -s $file, > 'Accept'=>'s', > 'Authorization'=> 'Basic '.encode_base64($usr.':'.$pwd)), > which did work locally but on a remote host it failed... > > I've had trouble with LWP::Simple in the past and had to use WWW:Mech > or even Mojo::UserAgent to make things work on windows, and I've tried > some of that... but really think curl is the easiest and least error > prone way... > > curl -v --user $usr:$pwd --data-binary @"$file" -X PUT "$url" > > > use MIME::Base64; > my $usr='admin'; > my $pwd='password'; > $ua->credentials($usr,$pwd); > > my $resp = $client->deploy_artifact( path => $path, properties => > $properties, file => $file,header=> HTTP::Headers->new( > 'Content-Type'=>'application/binary', > 'Content-Length'=> -s $file, > 'Accept'=>'s', > 'Authorization'=> 'Basic '.encode_base64($usr.':'.$pwd)), ); > print Dumper($resp); > > Like I said, I found that this worked locally, but I also had trouble > with it, got frustrated and used curl... I would like to understand > why I had to both encode the base64 in the header and do a ua-
> >credentials to make it work. With the above code, you can remove the
> AgentP and corresponding get_basic_credentials and it still works. > > I am quite surprised that your tests work and that mine do not. Basic > authentication requires a bit more than an empty header, which is what > I saw coming out of the box with no header arg supplied to > deploy_artifact. (basic out of the box is basic auth with admin- > password as creds) > > makes me want to develop a suite of tests that should work against an > artifactory local...using curl gets the job done for pushing a file is > fine, but no UA interface so it won't work with Artifactory::Client. > > > Thanks for the response! > --dave
Show quoted text
> my $h = HTTP::Headers->new(); > $h->authorization_basic( 'user', 'pass' ); > my $ua = LWP::UserAgent->new( default_headers => $h ); > my $resp = $ua->get($url);
Thanks, another way to provide the basic auth headers using LWP! :) This sadly does not seem to work. I'm not sure where the difference is, but remotely this code does not work. Show quoted text
> proxy node providing the authentication service between the client and > Artifactory?
nope, on the same network as the artifactory instance. I've tried quite a few things like: push @{ $ua->requests_redirectable }, 'POST'; push @{ $ua->requests_redirectable }, 'PUT'; $ua->max_redirect(1000); $ua->show_progress(true); haven't been able to make LWP::UserAgent work. when using curl I see that I am in fact connecting to port 8081 and the ip resolves to the host I would expect. I see Expect: 100-Continue [data not shown] and HTTP/1.1 201 Created response using curl (working!). With LWP::UserAgent, I see the PUT url and timeout with a 404 not found. [PATCH] dealing with mutiple HTTP 100 Continue responses http://code.activestate.com/lists/perl-libwww/5866/ Re: LWP::UserAgent and TCP_NODELAY - didn't know how to make MyHTTP be used by LWP::UserAgent... http://www.nntp.perl.org/group/perl.libwww/2005/12/msg6480.html I can provide wireshark output but I'm not sure that will provide anymore light. HTTP clients are still something that require a lot of attention... I don't know how to resolve it, aside from using a client that does handle the Continue responses. I'm not sure what is causing the difference between local and remote repo, and would be very happy if another person would duplicate such strange behavior. Thanks for trying to help everyone, --dave
I'm shooting from the hip here, but I'd suggest setting the Expect: 100-continue in HTTP request headers. On Mon Aug 18 14:51:19 2014, MRHORNER wrote: Show quoted text
> > my $h = HTTP::Headers->new(); > > $h->authorization_basic( 'user', 'pass' ); > > my $ua = LWP::UserAgent->new( default_headers => $h ); > > my $resp = $ua->get($url);
> Thanks, another way to provide the basic auth headers using LWP! :) > > This sadly does not seem to work. I'm not sure where the difference > is, but remotely this code does not work. >
> > proxy node providing the authentication service between the client > > and > > Artifactory?
> nope, on the same network as the artifactory instance. > > I've tried quite a few things like: > push @{ $ua->requests_redirectable }, 'POST'; > push @{ $ua->requests_redirectable }, 'PUT'; > $ua->max_redirect(1000); > $ua->show_progress(true); > > haven't been able to make LWP::UserAgent work. when using curl I see > that I am in fact connecting to port 8081 and the ip resolves to the > host I would expect. I see Expect: 100-Continue [data not shown] and > HTTP/1.1 201 Created response using curl (working!). With > LWP::UserAgent, I see the PUT url and timeout with a 404 not found. > > [PATCH] dealing with mutiple HTTP 100 Continue responses > http://code.activestate.com/lists/perl-libwww/5866/ > > Re: LWP::UserAgent and TCP_NODELAY - didn't know how to make MyHTTP be > used by LWP::UserAgent... > http://www.nntp.perl.org/group/perl.libwww/2005/12/msg6480.html > > I can provide wireshark output but I'm not sure that will provide > anymore light. > HTTP clients are still something that require a lot of attention... > I don't know how to resolve it, aside from using a client that does > handle the Continue responses. > > I'm not sure what is causing the difference between local and remote > repo, and would be very happy if another person would duplicate such > strange behavior. > > Thanks for trying to help everyone, > --dave
Many thanks, that does affect the runtime behavior. changed your suggested code with auth to include this: my $h = HTTP::Headers->new('Expect' => '100-continue'); $h->authorization_basic( $usr, $pwd ); and now the blocking is gone but in it's place I get a strange error. 500 Can't use an undefined value as a SCALAR reference HTTP::Response { Parents HTTP::Message public methods (22) : as_string, base, clone, code, current_age, dump, error_as_HTML, filename, fresh_until, freshness_lifetime, is_error, is_fresh, is_info, is_redirect, is_success, message, new, parse, previous, redirects, request, status_line private methods (0) internals: { _content "Can't use an undefined value as a SCALAR reference at C:/strawberry/perl/site/lib/LWP/Protocol/http.pm line 406. ", _headers HTTP::Headers, _msg "Can't use an undefined value as a SCALAR reference", _rc 500, _request HTTP::Request } Line 406 of http.pm is: if (defined($wbits) && $wbits =~ /[^\0]/) { which is checking the defined on the left hand side...hrm undefined value should be protected with that defined() check, right? Thanks. --dave On Mon Aug 18 23:36:22 2014, SYAGI wrote: Show quoted text
> I'm shooting from the hip here, but I'd suggest setting the Expect: > 100-continue in HTTP request headers. > > On Mon Aug 18 14:51:19 2014, MRHORNER wrote:
> > > my $h = HTTP::Headers->new(); > > > $h->authorization_basic( 'user', 'pass' ); > > > my $ua = LWP::UserAgent->new( default_headers => $h ); > > > my $resp = $ua->get($url);
> > Thanks, another way to provide the basic auth headers using LWP! :) > > > > This sadly does not seem to work. I'm not sure where the difference > > is, but remotely this code does not work. > >
> > > proxy node providing the authentication service between the client > > > and > > > Artifactory?
> > nope, on the same network as the artifactory instance. > > > > I've tried quite a few things like: > > push @{ $ua->requests_redirectable }, 'POST'; > > push @{ $ua->requests_redirectable }, 'PUT'; > > $ua->max_redirect(1000); > > $ua->show_progress(true); > > > > haven't been able to make LWP::UserAgent work. when using curl I see > > that I am in fact connecting to port 8081 and the ip resolves to the > > host I would expect. I see Expect: 100-Continue [data not shown] and > > HTTP/1.1 201 Created response using curl (working!). With > > LWP::UserAgent, I see the PUT url and timeout with a 404 not found. > > > > [PATCH] dealing with mutiple HTTP 100 Continue responses > > http://code.activestate.com/lists/perl-libwww/5866/ > > > > Re: LWP::UserAgent and TCP_NODELAY - didn't know how to make MyHTTP > > be > > used by LWP::UserAgent... > > http://www.nntp.perl.org/group/perl.libwww/2005/12/msg6480.html > > > > I can provide wireshark output but I'm not sure that will provide > > anymore light. > > HTTP clients are still something that require a lot of attention... > > I don't know how to resolve it, aside from using a client that does > > handle the Continue responses. > > > > I'm not sure what is causing the difference between local and remote > > repo, and would be very happy if another person would duplicate such > > strange behavior. > > > > Thanks for trying to help everyone, > > --dave
What exactly is http.pm? On my system I don't have that module installed. Can you try perldoc -l http? Also, what's the Data::Dumper output of the response object? I hadn't used this dumper thing you're using, and I think it misses some valuable information. On Mon Aug 25 13:06:40 2014, MRHORNER wrote: Show quoted text
> Many thanks, that does affect the runtime behavior. > > changed your suggested code with auth to include this: > my $h = HTTP::Headers->new('Expect' => '100-continue'); > $h->authorization_basic( $usr, $pwd ); > and now the blocking is gone but in it's place I get a strange error. > > 500 Can't use an undefined value as a SCALAR reference > HTTP::Response { > Parents HTTP::Message > public methods (22) : as_string, base, clone, code, current_age, > dump, error_as_HTML, filename, fresh_until, freshness_lifetime, > is_error, is_fresh, is_info, is_redirect, is_success, message, new, > parse, previous, redirects, request, status_line > private methods (0) > internals: { > _content "Can't use an undefined value as a SCALAR reference > at C:/strawberry/perl/site/lib/LWP/Protocol/http.pm line 406. > ", > _headers HTTP::Headers, > _msg "Can't use an undefined value as a SCALAR > reference", > _rc 500, > _request HTTP::Request > } > > Line 406 of http.pm is: > if (defined($wbits) && $wbits =~ /[^\0]/) { > which is checking the defined on the left hand side...hrm > > undefined value should be protected with that defined() check, right? > > Thanks. > --dave
Show quoted text
> What exactly is http.pm? On my system I don't have that module > installed. Can you try perldoc -l http?
Two windows systems tried perldoc -l http, both replied 'No documentation found for "http"' Show quoted text
> Also, what's the Data::Dumper output of the response object?
(sorry about the formatting) ----- $VAR1 = bless( { '_content' => 'Can\'t use an undefined value as a SCALAR reference at C:/strawberry/perl/sit e/lib/LWP/Protocol/http.pm line 406. ', '_rc' => 500, '_headers' => bless( { 'client-warning' => 'Internal response', 'client-date' => 'Wed, 27 Aug 2014 21:07:16 GMT', 'content-type' => 'text/plain', '::std_case' => { 'set-cookie2' => 'Set-Cookie2', 'client-warning' => 'Client-Warning', 'client-date' => 'Client-Date', 'set-cookie' => 'Set-Cookie' } }, 'HTTP::Headers' ), '_msg' => 'Can\'t use an undefined value as a SCALAR reference', '_request' => bless( { '_content' => sub { "DUMMY" }, '_uri' => bless( do{\(my $o = 'URLHERE')}, 'URI::http' ), '_headers' => bless( { 'user-agent' => 'libwww-perl/6.08', 'content-type' => 'application/binary', '_headers' => bless( { 'user-agent' => 'libwww-perl/6.08', 'content-type' => 'application/binary', 'accept' => 's', 'content-length' => 3675, 'expect' => '100-continue', 'authorization' => 'Basic ZZExpZmUxMA== ' }, 'HTTP::Headers' ), '_method' => 'PUT', '_uri_canonical' => $VAR1->{'_request'}{'_uri'} }, 'HTTP::Request' ) }, 'HTTP::Response' ); ----- The http.pm file didn't exist on another strawberry test machine, I am also surprised by it's presence. Wondering about just deleting it but haven't gone that far yet. Can\'t use an undefined value as a SCALAR reference, seems like something easy to resolve; Not sure why I am getting that error on a line that is testing for defined... I've attached both http.pm and https.pm found on my system. Thanks, --dave
Subject: http.pm

Message body is not shown because it is too large.

Subject: https.pm
package LWP::Protocol::https; use strict; our $VERSION = "6.04"; require LWP::Protocol::http; our @ISA = qw(LWP::Protocol::http); sub socket_type { return "https"; } sub _extra_sock_opts { my $self = shift; my %ssl_opts = %{$self->{ua}{ssl_opts} || {}}; if (delete $ssl_opts{verify_hostname}) { $ssl_opts{SSL_verify_mode} ||= 1; $ssl_opts{SSL_verifycn_scheme} = 'www'; } else { $ssl_opts{SSL_verify_mode} = 0; } if ($ssl_opts{SSL_verify_mode}) { unless (exists $ssl_opts{SSL_ca_file} || exists $ssl_opts{SSL_ca_path}) { eval { require Mozilla::CA; }; if ($@) { if ($@ =! /^Can't locate Mozilla\/CA\.pm/) { $@ = <<'EOT'; Can't verify SSL peers without knowing which Certificate Authorities to trust This problem can be fixed by either setting the PERL_LWP_SSL_CA_FILE envirionment variable or by installing the Mozilla::CA module. To disable verification of SSL peers set the PERL_LWP_SSL_VERIFY_HOSTNAME envirionment variable to 0. If you do this you can't be sure that you communicate with the expected peer. EOT } die $@; } $ssl_opts{SSL_ca_file} = Mozilla::CA::SSL_ca_file(); } } $self->{ssl_opts} = \%ssl_opts; return (%ssl_opts, $self->SUPER::_extra_sock_opts); } sub _check_sock { my($self, $req, $sock) = @_; my $check = $req->header("If-SSL-Cert-Subject"); if (defined $check) { my $cert = $sock->get_peer_certificate || die "Missing SSL certificate"; my $subject = $cert->subject_name; die "Bad SSL certificate subject: '$subject' !~ /$check/" unless $subject =~ /$check/; $req->remove_header("If-SSL-Cert-Subject"); # don't pass it on } } sub _get_sock_info { my $self = shift; $self->SUPER::_get_sock_info(@_); my($res, $sock) = @_; $res->header("Client-SSL-Cipher" => $sock->get_cipher); my $cert = $sock->get_peer_certificate; if ($cert) { $res->header("Client-SSL-Cert-Subject" => $cert->subject_name); $res->header("Client-SSL-Cert-Issuer" => $cert->issuer_name); } if (!$self->{ssl_opts}{SSL_verify_mode}) { $res->push_header("Client-SSL-Warning" => "Peer certificate not verified"); } elsif (!$self->{ssl_opts}{SSL_verifycn_scheme}) { $res->push_header("Client-SSL-Warning" => "Peer hostname match with certificate not verified"); } $res->header("Client-SSL-Socket-Class" => $Net::HTTPS::SSL_SOCKET_CLASS); } #----------------------------------------------------------- package LWP::Protocol::https::Socket; require Net::HTTPS; our @ISA = qw(Net::HTTPS LWP::Protocol::http::SocketMethods); 1; __END__ =head1 NAME LWP::Protocol::https - Provide https support for LWP::UserAgent =head1 SYNOPSIS use LWP::UserAgent; $ua = LWP::UserAgent->new(ssl_opts => { verify_hostname => 1 }); $res = $ua->get("https://www.example.com"); =head1 DESCRIPTION The LWP::Protocol::https module provides support for using https schemed URLs with LWP. This module is a plug-in to the LWP protocol handling, so you don't use it directly. Once the module is installed LWP is able to access sites using HTTP over SSL/TLS. If hostname verification is requested by LWP::UserAgent's C<ssl_opts>, and neither C<SSL_ca_file> nor C<SSL_ca_path> is set, then C<SSL_ca_file> is implied to be the one provided by Mozilla::CA. If the Mozilla::CA module isn't available SSL requests will fail. Either install this module, set up an alternative C<SSL_ca_file> or disable hostname verification. This module used to be bundled with the libwww-perl, but it was unbundled in v6.02 in order to be able to declare its dependencies properly for the CPAN tool-chain. Applications that need https support can just declare their dependency on LWP::Protocol::https and will no longer need to know what underlying modules to install. =head1 SEE ALSO L<IO::Socket::SSL>, L<Crypt::SSLeay>, L<Mozilla::CA> =head1 COPYRIGHT Copyright 1997-2011 Gisle Aas. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Ah I see, this is LWP::Protocol::http huh. The only thing I can think of is that you might be hitting a subtle bug on LWP side, could be some kind of race condition. You might want to try filing an issue here to see what they have to say about the error you're getting: https://github.com/libwww-perl/libwww-perl On Wed Aug 27 17:11:31 2014, MRHORNER wrote: Show quoted text
> > What exactly is http.pm? On my system I don't have that module > > installed. Can you try perldoc -l http?
> Two windows systems tried perldoc -l http, both replied 'No > documentation found for "http"' >
> > Also, what's the Data::Dumper output of the response object?
> (sorry about the formatting) > ----- > $VAR1 = bless( { > '_content' => 'Can\'t use an undefined value as a SCALAR reference at > C:/strawberry/perl/sit > e/lib/LWP/Protocol/http.pm line 406. > ', > '_rc' => 500, > '_headers' => bless( { > 'client-warning' => 'Internal response', > 'client-date' => 'Wed, 27 Aug 2014 21:07:16 GMT', > 'content-type' => 'text/plain', > '::std_case' => { > 'set-cookie2' => 'Set-Cookie2', > 'client-warning' => 'Client-Warning', > 'client-date' => 'Client-Date', > 'set-cookie' => 'Set-Cookie' > } > }, 'HTTP::Headers' ), > '_msg' => 'Can\'t use an undefined value as a SCALAR reference', > '_request' => bless( { > '_content' => sub { "DUMMY" }, > '_uri' => bless( do{\(my $o = 'URLHERE')}, 'URI::http' ), > '_headers' => bless( { > 'user-agent' => 'libwww-perl/6.08', > 'content-type' => 'application/binary', > > '_headers' => bless( { > 'user-agent' => 'libwww-perl/6.08', > 'content-type' => 'application/binary', > 'accept' => 's', > 'content-length' => 3675, > 'expect' => '100-continue', > 'authorization' > => 'Basic ZZExpZmUxMA== > ' > }, 'HTTP::Headers' ), > '_method' => 'PUT', > '_uri_canonical' => $VAR1->{'_request'}{'_uri'} > }, 'HTTP::Request' ) > }, 'HTTP::Response' ); > ----- > The http.pm file didn't exist on another strawberry test machine, I am > also surprised by it's presence. Wondering about just deleting it but > haven't gone that far yet. > > Can\'t use an undefined value as a SCALAR reference, seems like > something easy to resolve; Not sure why I am getting that error on a > line that is testing for defined... I've attached both http.pm and > https.pm found on my system. > > > Thanks, > --dave
No problem, I hope they can help you out with this. I'll look at the issue from time to time. On Thu Aug 28 16:57:07 2014, MRHORNER wrote: Show quoted text